From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 8A0D91F4BE for ; Sat, 29 Jun 2019 19:59:53 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 08/11] parentpipe: document and use one-shot wakeups Date: Sat, 29 Jun 2019 19:59:48 +0000 Message-Id: <20190629195951.32160-9-e@80x24.org> In-Reply-To: <20190629195951.32160-1-e@80x24.org> References: <20190629195951.32160-1-e@80x24.org> List-Id: The master process only dies once and we close ourselves right away. So it doesn't matter if it's level-triggered or edge-triggered, actually, but one-shot is most consistent with our use and keeps the kernel from doing extra work. --- lib/PublicInbox/ParentPipe.pm | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/PublicInbox/ParentPipe.pm b/lib/PublicInbox/ParentPipe.pm index ccc0815e..6ef51c1a 100644 --- a/lib/PublicInbox/ParentPipe.pm +++ b/lib/PublicInbox/ParentPipe.pm @@ -1,20 +1,24 @@ # Copyright (C) 2016-2018 all contributors # License: AGPL-3.0+ -# only for PublicInbox::Daemon + +# only for PublicInbox::Daemon, allows worker processes to be +# notified if the master process dies. package PublicInbox::ParentPipe; use strict; use warnings; use base qw(PublicInbox::DS); use fields qw(cb); +use PublicInbox::Syscall qw(EPOLLIN EPOLLONESHOT); sub new ($$$) { - my ($class, $pipe, $cb) = @_; + my ($class, $pipe, $worker_quit) = @_; my $self = fields::new($class); - $self->SUPER::new($pipe, PublicInbox::DS::EPOLLIN()); - $self->{cb} = $cb; + $self->SUPER::new($pipe, EPOLLIN|EPOLLONESHOT); + $self->{cb} = $worker_quit; $self; } +# master process died, time to call worker_quit ourselves sub event_step { $_[0]->{cb}->($_[0]) } 1; -- EW