Commit d5ef6a61 authored by Deathcrow's avatar Deathcrow
Browse files

Final (?) Timeout fix for

parent 4d46b0a5
......@@ -8,9 +8,9 @@ import argparse
import copy
import multiprocessing
import os
import pickle
import re
import random
import select
import signal
import subprocess
import tempfile
......@@ -111,10 +111,12 @@ def process_proc_tcpprobe_optimized(sender): #sampling
starty = time.perf_counter()
unprocessed_senders = set([key for key in range(len(sender))])
tcpprobe_proc = open("/proc/net/tcpprobe", "r")
tcpprobe_poll = select.poll()
tcpprobe_poll.register(tcpprobe_proc, select.POLLIN) # register poll to check for read-available data in file
# collect line from tcpprobe and write to file if it belongs to a
# unprocessed (one that didn't have a line written yet) sender
while (len(unprocessed_senders) > 0) and (time.perf_counter() - starty < float(args.samplerate)): # find line matching all senders && TIMEOUT
while (len(unprocessed_senders) > 0) and (time.perf_counter() - starty < float(args.samplerate)) and tcpprobe_poll.poll(int(float(args.samplerate) * 1000)): # find line matching all senders && TIMEOUT
line_split = tcpprobe_proc.readline().split(" ")
# try to match current tcpprobe line against all unprocessed senders
for key in unprocessed_senders:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment