about summary refs log tree commit homepage
path: root/lib/PublicInbox/EvCleanup.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-06-10 03:21:37 +0000
committerEric Wong <e@80x24.org>2019-06-10 05:05:15 +0000
commitb1fca235b174d4e3df674fd301e7bfba222a9e97 (patch)
treec3df2812f9f1eef650677ed2da1c8312596110a3 /lib/PublicInbox/EvCleanup.pm
parent6feb58ba2e9dee57b474e82e871a8945b537325e (diff)
downloadpublic-inbox-b1fca235b174d4e3df674fd301e7bfba222a9e97.tar.gz
If we got something to write, then write it.  Otherwise, try
reading; and continue dealing with errors which normally occur
along the way.

Trying to read requests while we need to buffer in luserspace
is suicidal from a memory management standpoint.

The only adjustment needed for existing callers is EvCleanup;
where we need to ensure we're always calling the dummy
EvCleanup::event_write callback to accomplish nothing.
Diffstat (limited to 'lib/PublicInbox/EvCleanup.pm')
-rw-r--r--lib/PublicInbox/EvCleanup.pm8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/PublicInbox/EvCleanup.pm b/lib/PublicInbox/EvCleanup.pm
index afed24ff..f76fb681 100644
--- a/lib/PublicInbox/EvCleanup.pm
+++ b/lib/PublicInbox/EvCleanup.pm
@@ -6,7 +6,6 @@ package PublicInbox::EvCleanup;
 use strict;
 use warnings;
 use base qw(PublicInbox::DS);
-use fields qw(rd);
 
 my $ENABLED;
 sub enabled { $ENABLED }
@@ -25,7 +24,12 @@ sub once_init () {
         pipe($r, $w) or die "pipe: $!";
         fcntl($w, 1031, 4096) if $^O eq 'linux'; # 1031: F_SETPIPE_SZ
         $self->SUPER::new($w);
-        $self->{rd} = $r; # never read, since we never write..
+
+        # always writable, since PublicInbox::EvCleanup::event_write
+        # never drains wbuf.  We can avoid wasting a hash slot by
+        # stuffing the read-end of the pipe into the never-to-be-touched
+        # wbuf
+        push @{$self->{wbuf}}, $r;
         $self;
 }