From 0ac7fb08ce9b39e0ff02435bb413720050021569 Mon Sep 17 00:00:00 2001 From: Tobi Oetiker Date: Mon, 9 Jun 2008 21:57:38 +0000 Subject: let the server only return if he has something to say. --- qooxdoo/source/perl/Qooxdoo/Services/Tr.pm | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'qooxdoo/source/perl') diff --git a/qooxdoo/source/perl/Qooxdoo/Services/Tr.pm b/qooxdoo/source/perl/Qooxdoo/Services/Tr.pm index 1d7e192..a8e3c10 100644 --- a/qooxdoo/source/perl/Qooxdoo/Services/Tr.pm +++ b/qooxdoo/source/perl/Qooxdoo/Services/Tr.pm @@ -23,7 +23,7 @@ sub launch { } chdir '/' or die "Can't chdir to /: $!"; - $|++; # unbuffer +# $|++; # unbuffer open STDOUT, ">>/tmp/tr_session.$$" or die "Can't write to /tmp/tr_session.$$: $!"; open STDIN, '/dev/null' or die "Can't read /dev/null: $!"; @@ -109,13 +109,11 @@ sub method_run_tr # print STDERR "$again, $handle, $size, $point\n"; $rounds ++; } while ($again and $point >= $size); + print STDERR "$point > $size\n"; if (seek $fh, $point,0){ while (<$fh>){ -# print STDERR $_; - waitpid($handle,WNOHANG); - /^traceroute to/ && next; - last unless /\n$/; # stop when we find an incomplete line - chomp; + #print STDERR ">$_<"; + next if /^\s*$/ or /traceroute to/; if (/^\s*(\d+)\s+(\S+)\s+\((\S+?)\)\s+(\S+)\s+ms/){ my ($hop,$host,$ip,$value) = ($1,$2,$3,$4); $value = undef unless $value =~ /^\d+(\.\d+)?$/; @@ -127,10 +125,12 @@ sub method_run_tr elsif (/^SLEEP\s+(\d+)/){ push @array, ['SLEEP',$1]; } - else { - s/traceroute:\s*//g; + elsif (s/traceroute:\s*//g or /\n$/){ push @array, ['INFO',$_]; } + else { + last; + } $point = tell($fh); }; close $fh; -- cgit v1.2.3-24-g4f1b