about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-09-08 10:41:12 +0000
committerEric Wong <e@80x24.org>2019-09-08 10:42:12 +0000
commit16d96f80e55d3f40338101ee8641e03f3b4f2d64 (patch)
tree63ed51c37bf17a04f5a2bda5cfe8942c7e1c5e9e
parent25cd95498bfd30f7436cdf782feec0d3ca76f837 (diff)
downloadpublic-inbox-16d96f80e55d3f40338101ee8641e03f3b4f2d64.tar.gz
We don't want to get hung into a state where we see "\n" via
index(), yet cannot consume rbuf in the while loop.  So tweak
the regexp to ensure we always consume rbuf.

I suspect this is what causes occasional 100% CPU usage of
-nntpd, but reproducing it's been difficult..
-rw-r--r--lib/PublicInbox/NNTP.pm2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm
index 41f1e9c1..c0496852 100644
--- a/lib/PublicInbox/NNTP.pm
+++ b/lib/PublicInbox/NNTP.pm
@@ -995,7 +995,7 @@ sub event_step {
                 my $off = bytes::length($$rbuf);
                 $r = $self->do_read($rbuf, LINE_MAX, $off) or return;
         }
-        while ($r > 0 && $$rbuf =~ s/\A[ \t\r\n]*([^\r\n]*)\r?\n//) {
+        while ($r > 0 && $$rbuf =~ s/\A[ \t]*([^\n]*?)\r?\n//) {
                 my $line = $1;
                 return $self->close if $line =~ /[[:cntrl:]]/s;
                 my $t0 = now();