lib/PublicInbox/IMAP.pm | 4 ++++ lib/PublicInbox/InboxIdle.pm | 4 ++++ t/nntpd.t | 34 ++++++++++++++++------------------ diff --git a/lib/PublicInbox/IMAP.pm b/lib/PublicInbox/IMAP.pm index 9ae7c60e75ee161eb276b23d750fa65c4ea9a7ce..d4ef6efe156d2b3efde19d4eafa08aa3a760b73d 100644 --- a/lib/PublicInbox/IMAP.pm +++ b/lib/PublicInbox/IMAP.pm @@ -1462,6 +1462,10 @@ # for graceful shutdown in PublicInbox::Daemon: sub busy { my ($self, $now) = @_; + if (defined($self->{-idle_tag})) { + $self->write(\"* BYE server shutting down\r\n"); + return; # not busy anymore + } ($self->{rbuf} || $self->{wbuf} || $self->not_idle_long($now)); } diff --git a/lib/PublicInbox/InboxIdle.pm b/lib/PublicInbox/InboxIdle.pm index d60d4f239c381e2d8fd07d0247a016da78e30269..d0bb43c58486a5900348a74031cb44f95820bf74 100644 --- a/lib/PublicInbox/InboxIdle.pm +++ b/lib/PublicInbox/InboxIdle.pm @@ -79,4 +79,8 @@ eval { $self->{inot}->poll }; # Linux::Inotify2::poll warn "$self->{inot}->poll err: $@\n" if $@; } +# for graceful shutdown in PublicInbox::Daemon, +# just ensure the FD gets closed ASAP and subscribers +sub busy { 0 } + 1; diff --git a/t/nntpd.t b/t/nntpd.t index d6042d18758def810762ab812a04e0442d5aa1a7..b24720eb9dd0c323158995b0a4c3532e1829ba6d 100644 --- a/t/nntpd.t +++ b/t/nntpd.t @@ -316,23 +316,6 @@ skip('lsof broken', 1) if (!scalar(@of) || $?); my @xap = grep m!Search/Xapian!, @of; is_deeply(\@xap, [], 'Xapian not loaded in nntpd'); } - { - setsockopt($s, IPPROTO_TCP, TCP_NODELAY, 1); - syswrite($s, 'HDR List-id 1-'); - select(undef, undef, undef, 0.15); - ok($td->kill, 'killed nntpd'); - select(undef, undef, undef, 0.15); - syswrite($s, "\r\n"); - $buf = ''; - do { - sysread($s, $buf, 4096, length($buf)); - } until ($buf =~ /\r\n\z/); - my @r = split("\r\n", $buf); - like($r[0], qr/^5\d\d /, - 'got 5xx response for unoptimized HDR'); - is(scalar @r, 1, 'only one response line'); - } - # -compact requires Xapian SKIP: { require_mods('Search::Xapian', 2); @@ -356,7 +339,22 @@ skip "lsof /(deleted)/ check untested on $^O", 1; my @of = xqx([$lsof, '-p', $td->{pid}], undef, $noerr); is(scalar(grep(/\(deleted\)/, @of)), 0, 'no deleted files'); }; - + { + setsockopt($s, IPPROTO_TCP, TCP_NODELAY, 1); + syswrite($s, 'HDR List-id 1-'); + select(undef, undef, undef, 0.15); + ok($td->kill, 'killed nntpd'); + select(undef, undef, undef, 0.15); + syswrite($s, "\r\n"); + $buf = ''; + do { + sysread($s, $buf, 4096, length($buf)); + } until ($buf =~ /\r\n\z/); + my @r = split("\r\n", $buf); + like($r[0], qr/^5\d\d /, + 'got 5xx response for unoptimized HDR'); + is(scalar @r, 1, 'only one response line'); + } $n = $s = undef; $td->join; is($?, 0, 'no error in exited process');