]> Sergey Matveev's repositories - public-inbox.git/commitdiff
nntpd: move busy check to NNTP package
authorEric Wong <e@80x24.org>
Thu, 24 Sep 2015 03:37:18 +0000 (03:37 +0000)
committerEric Wong <e@80x24.org>
Thu, 24 Sep 2015 06:58:31 +0000 (06:58 +0000)
This is better encapsulated and hopefully more readable.
While we're at it, check for being inside a long response, too.

lib/PublicInbox/NNTP.pm
public-inbox-nntpd

index 0d0de976f562454c0c3443eed3c95cbbf6a9f6b7..52d6a64c2db45119953cc06d55d41ec59bcd0404 100644 (file)
@@ -919,4 +919,9 @@ sub watch_read {
        $rv;
 }
 
+sub busy () {
+       my ($self) = @_;
+       ($self->{rbuf} ne '' || $self->{long_res} || $self->{write_buf_size});
+}
+
 1;
index 4c1560803e221c279be82a4de40637a6ee06393c..70bab46f304bc121ef1bf62b570665f79c0a669d 100644 (file)
@@ -205,7 +205,7 @@ sub worker_quit {
 
                foreach my $s (values %$dmap) {
                        next unless ref($s) eq 'PublicInbox::NNTP';
-                       if ($s->{write_buf_size} || $s->{rbuf}) {
+                       if ($s->busy) {
                                ++$n;
                        } else {
                                $s->close;