From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) 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.0 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 945491FAE7 for ; Tue, 6 Mar 2018 08:42:42 +0000 (UTC) From: "Eric Wong (Contractor, The Linux Foundation)" To: meta@public-inbox.org Subject: [PATCH 05/34] evcleanup: disable outside of daemon Date: Tue, 6 Mar 2018 08:42:13 +0000 Message-Id: <20180306084242.19988-6-e@80x24.org> In-Reply-To: <20180306084242.19988-1-e@80x24.org> References: <20180306084242.19988-1-e@80x24.org> List-Id: We'll be using these in a more OO manner for V2Writable (which doesn't use Danga::Socket), so lets not unnecessarily register cleanup handlers intended for network daemons. --- lib/PublicInbox/Daemon.pm | 1 + lib/PublicInbox/EvCleanup.pm | 2 ++ lib/PublicInbox/Inbox.pm | 1 + 3 files changed, 4 insertions(+) diff --git a/lib/PublicInbox/Daemon.pm b/lib/PublicInbox/Daemon.pm index 0329bd3..9d27d2b 100644 --- a/lib/PublicInbox/Daemon.pm +++ b/lib/PublicInbox/Daemon.pm @@ -460,6 +460,7 @@ sub daemon_loop ($$) { @listeners = map { PublicInbox::Listener->new($_, $post_accept) } @listeners; + $PublicInbox::EvCleanup::ENABLED = 1; Danga::Socket->EventLoop; $parent_pipe = undef; } diff --git a/lib/PublicInbox/EvCleanup.pm b/lib/PublicInbox/EvCleanup.pm index 559730e..8ed5180 100644 --- a/lib/PublicInbox/EvCleanup.pm +++ b/lib/PublicInbox/EvCleanup.pm @@ -7,6 +7,8 @@ use strict; use warnings; use base qw(Danga::Socket); use fields qw(rd); + +our $ENABLED; my $singleton; my $asapq = [ [], undef ]; my $nextq = [ [], undef ]; diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm index 54a6eb3..b9cd4c4 100644 --- a/lib/PublicInbox/Inbox.pm +++ b/lib/PublicInbox/Inbox.pm @@ -29,6 +29,7 @@ sub cleanup_task () { sub _cleanup_later ($) { my ($self) = @_; + return unless $PublicInbox::EvCleanup::ENABLED; $cleanup_timer ||= PublicInbox::EvCleanup::later(*cleanup_task); $CLEANUP->{"$self"} = $self; } -- EW