From 9da6fcbb3e6d720a4b575a48063ecf3240a44022 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 30 Apr 2016 02:57:40 +0000 Subject: daemon: graceful shutdown warning and limit removal git clones may take longer than 30s, much longer... So prepare to wait almost indefinitely for sockets to timeout and document the second signal behavior for immediate shutdown. While we're at it, move parent death handling to a separate class to avoid Danga::Socket->AddOtherFds, since that does not allow proper handling the parent pipe being closed and would actually misterminate a worker prematurely. t/nntpd.t is update to illustrate the failure with workers enabled. We will work to keep memory usage low and let clients take their time without interrupting them. --- lib/PublicInbox/ParentPipe.pm | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 lib/PublicInbox/ParentPipe.pm (limited to 'lib/PublicInbox/ParentPipe.pm') diff --git a/lib/PublicInbox/ParentPipe.pm b/lib/PublicInbox/ParentPipe.pm new file mode 100644 index 00000000..d2d054ce --- /dev/null +++ b/lib/PublicInbox/ParentPipe.pm @@ -0,0 +1,21 @@ +# Copyright (C) 2016 all contributors +# License: AGPL-3.0+ +# only for PublicInbox::Daemon +package PublicInbox::ParentPipe; +use strict; +use warnings; +use base qw(Danga::Socket); +use fields qw(cb); + +sub new ($$$) { + my ($class, $pipe, $cb) = @_; + my $self = fields::new($class); + $self->SUPER::new($pipe); + $self->{cb} = $cb; + $self->watch_read(1); + $self; +} + +sub event_read { $_[0]->{cb}->($_[0]) } + +1; -- cgit v1.2.3-24-ge0c7