unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
* [PATCH] nntp: regexp always consumes rbuf if "\n" exists
@ 2019-09-08 10:45 Eric Wong
  2019-09-08 10:52 ` trying to figure out 100% CPU usage in nntpd Eric Wong
  0 siblings, 1 reply; 21+ messages in thread
From: Eric Wong @ 2019-09-08 10:45 UTC (permalink / raw)
  To: meta

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..
---
 lib/PublicInbox/NNTP.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm
index 41f1e9c..c049685 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();
-- 
EW


^ permalink raw reply related	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2019-09-14  5:25 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-08 10:45 [PATCH] nntp: regexp always consumes rbuf if "\n" exists Eric Wong
2019-09-08 10:52 ` trying to figure out 100% CPU usage in nntpd Eric Wong
2019-09-09 10:05   ` Konstantin Ryabitsev
2019-09-09 17:53     ` Eric Wong
2019-09-10  8:38       ` Konstantin Ryabitsev
2019-09-10 18:12         ` Eric Wong
2019-09-11  2:22           ` httpd 502s [was: trying to figure out 100% CPU usage in nntpd...] Eric Wong
2019-09-11 10:24             ` Konstantin Ryabitsev
2019-09-11 17:12               ` Eric Wong
2019-09-11 17:36                 ` Konstantin Ryabitsev
2019-09-12  0:05                   ` Eric Wong
2019-09-12  2:49                     ` Eric Wong
2019-09-12  8:35                       ` Eric Wong
2019-09-12 11:37                         ` Konstantin Ryabitsev
2019-09-13  3:12                           ` Eric Wong
2019-09-13  7:03                             ` Eric Wong
2019-09-13  9:01                             ` Eric Wong
2019-09-13 18:07                             ` Konstantin Ryabitsev
2019-09-14  5:25                               ` Eric Wong
2019-09-11  9:44           ` trying to figure out 100% CPU usage in nntpd Konstantin Ryabitsev
2019-09-11 17:12             ` Eric Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).