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 7D6BE1F462; Mon, 3 Jun 2019 09:03:07 +0000 (UTC) Date: Mon, 3 Jun 2019 09:03:07 +0000 From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 7/6] ds: remove PLCMap and per-socket PostLoopCallback Message-ID: <20190603090307.v2lvqwf2hb4tun64@whir> References: <20190603015206.7871-1-e@80x24.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190603015206.7871-1-e@80x24.org> List-Id: We don't need and won't be needing per-socket PostLoopCallbacks. --- lib/PublicInbox/DS.pm | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm index 6b04e76..03612ce 100644 --- a/lib/PublicInbox/DS.pm +++ b/lib/PublicInbox/DS.pm @@ -58,7 +58,6 @@ our ( @ToClose, # sockets to close when event loop is done $PostLoopCallback, # subref to call at the end of each loop, if defined (global) - %PLCMap, # fd (num) -> PostLoopCallback (per-object) $LoopTimeout, # timeout of event loop in milliseconds $DoneInit, # if we've done the one-time module init yet @@ -85,7 +84,6 @@ sub Reset { @Timers = (); $PostLoopCallback = undef; - %PLCMap = (); $DoneInit = 0; # NOTE kqueue is close-on-fork, and we don't account for it, yet @@ -389,18 +387,8 @@ The callback function will be passed two parameters: \%DescriptorMap sub SetPostLoopCallback { my ($class, $ref) = @_; - if (ref $class) { - # per-object callback - my PublicInbox::DS $self = $class; - if (defined $ref && ref $ref eq 'CODE') { - $PLCMap{$self->{fd}} = $ref; - } else { - delete $PLCMap{$self->{fd}}; - } - } else { - # global callback - $PostLoopCallback = (defined $ref && ref $ref eq 'CODE') ? $ref : undef; - } + # global callback + $PostLoopCallback = (defined $ref && ref $ref eq 'CODE') ? $ref : undef; } # Internal function: run the post-event callback, send read events @@ -426,11 +414,6 @@ sub PostEventLoop { # or global) cancels it my $keep_running = 1; - # per-object post-loop-callbacks - for my $plc (values %PLCMap) { - $keep_running &&= $plc->(\%DescriptorMap); - } - # now we're at the very end, call callback if defined if (defined $PostLoopCallback) { $keep_running &&= $PostLoopCallback->(\%DescriptorMap); @@ -580,10 +563,6 @@ sub _cleanup { } } - # now delete from mappings. this fd no longer belongs to us, so we don't want - # to get alerts for it if it becomes writable/readable/etc. - delete $PLCMap{$self->{fd}}; - # we explicitly don't delete from DescriptorMap here until we # actually close the socket, as we might be in the middle of # processing an epoll_wait/etc that returned hundreds of fds, one -- EW