]> git.sesse.net Git - remoteglot/blobdiff - varnishcount.pl
Fix an issue where varnishcount would undercount on low traffic.
[remoteglot] / varnishcount.pl
index 1aa0e6f8f487659940355e95f96e9ec0a0b7df4d..7411b054c0a1d010b790794fb1a569f8fc8d19b1 100755 (executable)
@@ -12,13 +12,17 @@ open my $fh, "-|", "varnishncsa -F '%{%s}t %U %q tffb=%{Varnish:time_firstbyte}x
        or die "varnishncsa: $!";
 my %uniques = ();
 
-my $ev = AnyEvent->io(
+my $ev = AnyEvent::Handle->new(
        fh => $fh,
-        poll => 'r',
-       cb => sub {
-               chomp (my $input = <$fh>);
-               handle_line($input);
-       }
+       on_read => sub {
+               my ($hdl) = @_;
+               $hdl->push_read(
+                       line => sub {
+                               my ($hdl, $line, $eof) = @_;
+                               handle_line($line);
+                       }
+               );
+       },
 );
 my $ev2 = AnyEvent->timer(
        interval => 1.0,