]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/DS.pm
nntp: reduce memory overhead of zlib
[public-inbox.git] / lib / PublicInbox / DS.pm
index a82360239f43a79e86eaf97f7afcbf0149f29858..b16b189629ff16d459bc7c79bb0155e43d9642ea 100644 (file)
@@ -259,17 +259,8 @@ sub PostEventLoop {
     # now we can close sockets that wanted to close during our event processing.
     # (we didn't want to close them during the loop, as we didn't want fd numbers
     #  being reused and confused during the event loop)
-    while (my $sock = shift @ToClose) {
-        my $fd = fileno($sock);
-
-        # close the socket. (not a PublicInbox::DS close)
-        CORE::close($sock);
-
-        # and now we can finally remove the fd from the map.  see
-        # comment above in ->close.
-        delete $DescriptorMap{$fd};
-    }
-
+    delete($DescriptorMap{fileno($_)}) for @ToClose;
+    @ToClose = (); # let refcounting drop everything all at once
 
     # by default we keep running, unless a postloop callback (either per-object
     # or global) cancels it
@@ -449,6 +440,7 @@ sub do_read ($$$;$) {
     if ($! == EAGAIN) {
         epwait($sock, epbit($sock, EPOLLIN) | EPOLLONESHOT);
         rbuf_idle($self, $rbuf);
+        0;
     } else {
         $self->close;
     }
@@ -561,14 +553,15 @@ sub msg_more ($$) {
             return 0;
         }
     }
-    $self->write(\($_[1]));
+
+    # don't redispatch into NNTPdeflate::write
+    PublicInbox::DS::write($self, \($_[1]));
 }
 
 sub epwait ($$) {
     my ($sock, $ev) = @_;
     epoll_ctl($Epoll, EPOLL_CTL_MOD, fileno($sock), $ev) and
         confess("EPOLL_CTL_MOD $!");
-    0;
 }
 
 # return true if complete, false if incomplete (or failure)
@@ -579,8 +572,10 @@ sub accept_tls_step ($) {
     return $self->close if $! != EAGAIN;
     epwait($sock, PublicInbox::TLS::epollbit() | EPOLLONESHOT);
     unshift @{$self->{wbuf} ||= []}, \&accept_tls_step;
+    0;
 }
 
+# return true if complete, false if incomplete (or failure)
 sub shutdn_tls_step ($) {
     my ($self) = @_;
     my $sock = $self->{sock} or return;
@@ -588,6 +583,7 @@ sub shutdn_tls_step ($) {
     return $self->close if $! != EAGAIN;
     epwait($sock, PublicInbox::TLS::epollbit() | EPOLLONESHOT);
     unshift @{$self->{wbuf} ||= []}, \&shutdn_tls_step;
+    0;
 }
 
 # don't bother with shutdown($sock, 2), we don't fork+exec w/o CLOEXEC