From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 3D1061F429 for ; Sun, 26 Mar 2023 10:52:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1679827967; bh=Fo5SA3z6/m7akx2hdSdD4Ywl4bJprp1S/nAPNwseM/I=; h=From:To:Subject:Date:In-Reply-To:References:From; b=iWSql4dum0d0bV3cTv0MpIm5rzPTYX+sxxgYSlpfd1+jjHhLW8XvGvzXsKIsBkv5R TqyNwET1ln0cem11yA6rWIfhYyYOAsHMskzFHW0UrfwjbSbHda053wLUrmnJ2wDlu0 xHgNc2C2TKGJorEiM4pOKvEnRnJOcrMk2K23esd8= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/2] watch: do not recreate signalfd on SIGHUP Date: Sun, 26 Mar 2023 10:52:46 +0000 Message-Id: <20230326105246.2159382-3-e@80x24.org> In-Reply-To: <20230326105246.2159382-1-e@80x24.org> References: <20230326105246.2159382-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: The normal method by which PublicInbox::DS::event_loop sets up signals once needs some coercing to work with -watch. Otherwise, we'll end up wasting FDs every time somebody reloads -watch via SIGHUP. --- lib/PublicInbox/Watch.pm | 5 +++-- script/public-inbox-watch | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/Watch.pm b/lib/PublicInbox/Watch.pm index 810fb63b..693c7181 100644 --- a/lib/PublicInbox/Watch.pm +++ b/lib/PublicInbox/Watch.pm @@ -528,7 +528,8 @@ sub watch_nntp_init ($$) { sub watch { # main entry point my ($self, $sig, $oldset) = @_; $self->{oldset} = $oldset; - $self->{sig} = $sig; + my $first_sig; + $self->{sig} //= ($first_sig = $sig); my $poll = {}; # intvl_seconds => [ uri1, uri2 ] watch_imap_init($self, $poll) if $self->{imap}; watch_nntp_init($self, $poll) if $self->{nntp}; @@ -538,7 +539,7 @@ sub watch { # main entry point } watch_fs_init($self) if $self->{mdre}; local @PublicInbox::DS::post_loop_do = (sub { !$self->quit_done }); - PublicInbox::DS::event_loop($sig, $oldset); # calls ->event_step + PublicInbox::DS::event_loop($first_sig, $oldset); # calls ->event_step _done_for_now($self); } diff --git a/script/public-inbox-watch b/script/public-inbox-watch index 4c50461f..2fb27343 100755 --- a/script/public-inbox-watch +++ b/script/public-inbox-watch @@ -27,6 +27,7 @@ my $reload = sub { $watch->quit; $watch = PublicInbox::Watch->new(PublicInbox::Config->new); if ($watch) { + $watch->{sig} = $prev->{sig}; # prevent redundant signalfd warn "# reloaded\n"; } else { warn("E: reloading failed\n");