about summary refs log tree commit homepage
path: root/lib/PublicInbox/DS.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-06-24 02:52:33 +0000
committerEric Wong <e@80x24.org>2019-06-24 05:26:26 +0000
commit2101e27b937893aa427d8693161966e3673b887e (patch)
tree1a538c0d2a24ab06e37927a3a642eed47432f40f /lib/PublicInbox/DS.pm
parentc100879166cbbd6c2481ce68a549dab7d018d826 (diff)
downloadpublic-inbox-2101e27b937893aa427d8693161966e3673b887e.tar.gz
Both NNTP and HTTP have common needs and we can factor
out some common code to make dealing with IO::Socket::SSL
easier.
Diffstat (limited to 'lib/PublicInbox/DS.pm')
-rw-r--r--lib/PublicInbox/DS.pm10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm
index 9811405b..8735e888 100644
--- a/lib/PublicInbox/DS.pm
+++ b/lib/PublicInbox/DS.pm
@@ -473,6 +473,15 @@ next_buf:
     1; # all done
 }
 
+sub do_read ($$$$) {
+    my ($self, $rbuf, $len, $off) = @_;
+    my $r = sysread($self->{sock}, $$rbuf, $len, $off);
+    return ($r == 0 ? $self->close : $r) if defined $r;
+    # common for clients to break connections without warning,
+    # would be too noisy to log here:
+    $! == EAGAIN ? $self->watch_in1 : $self->close;
+}
+
 sub write_in_full ($$$$) {
     my ($fh, $bref, $len, $off) = @_;
     my $rv = 0;
@@ -583,6 +592,7 @@ sub watch ($$) {
         $KQueue->EV_SET($fd, EVFILT_READ(), kq_flag(EPOLLIN, $ev));
         $KQueue->EV_SET($fd, EVFILT_WRITE(), kq_flag(EPOLLOUT, $ev));
     }
+    0;
 }
 
 sub watch_in1 ($) { watch($_[0], EPOLLIN | EPOLLONESHOT) }