]> Sergey Matveev's repositories - public-inbox.git/blob - lib/PublicInbox/ParentPipe.pm
sigfd: simplify loop and improve documentation
[public-inbox.git] / lib / PublicInbox / ParentPipe.pm
1 # Copyright (C) 2016-2019 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
3
4 # only for PublicInbox::Daemon, allows worker processes to be
5 # notified if the master process dies.
6 package PublicInbox::ParentPipe;
7 use strict;
8 use warnings;
9 use base qw(PublicInbox::DS);
10 use fields qw(cb);
11 use PublicInbox::Syscall qw(EPOLLIN EPOLLONESHOT);
12
13 sub new ($$$) {
14         my ($class, $pipe, $worker_quit) = @_;
15         my $self = fields::new($class);
16         $self->SUPER::new($pipe, EPOLLIN|EPOLLONESHOT);
17         $self->{cb} = $worker_quit;
18         $self;
19 }
20
21 # master process died, time to call worker_quit ourselves
22 sub event_step {
23         $_[0]->close; # PublicInbox::DS::close
24         $_[0]->{cb}->();
25 }
26
27 1;