1 # This library is free software; you can redistribute it and/or modify
2 # it under the same terms as Perl itself.
4 # This license differs from the rest of public-inbox
6 # This is a fork of the (for now) unmaintained Danga::Socket 1.61.
7 # Unused features will be removed, and updates will be made to take
8 # advantage of newer kernels.
10 # API changes to diverge from Danga::Socket will happen to better
11 # accomodate new features and improve scalability. Do not expect
12 # this to be a stable API like Danga::Socket.
13 # Bugs encountered (and likely fixed) are reported to
14 # bug-Danga-Socket@rt.cpan.org and visible at:
15 # https://rt.cpan.org/Public/Dist/Display.html?Name=Danga-Socket
16 package PublicInbox::DS;
22 use Fcntl qw(FD_CLOEXEC F_SETFD F_GETFD);
26 use PublicInbox::Syscall qw(:epoll);
28 use fields ('sock', # underlying socket
29 'fd', # numeric file descriptor
30 'write_buf', # arrayref of scalars, scalarrefs, or coderefs to write
31 'write_buf_offset', # offset into first array of write_buf to start writing at
32 'write_buf_size', # total length of data in all write_buf items
33 'closed', # bool: socket is closed
34 'event_watch', # bitmask of events the client is interested in (POLLIN,OUT,etc.)
37 use Errno qw(EINPROGRESS EWOULDBLOCK EISCONN ENOTSOCK
38 EPIPE EAGAIN EBADF ECONNRESET ENOPROTOOPT);
39 use Carp qw(croak confess);
41 use constant DebugLevel => 0;
43 use constant POLLIN => 1;
44 use constant POLLOUT => 4;
45 use constant POLLERR => 8;
46 use constant POLLHUP => 16;
47 use constant POLLNVAL => 32;
49 our $HAVE_KQUEUE = eval { require IO::KQueue; 1 };
52 $HaveEpoll, # Flag -- is epoll available? initially undefined.
54 %DescriptorMap, # fd (num) -> PublicInbox::DS object
55 $Epoll, # Global epoll fd (for epoll mode only)
56 $KQueue, # Global kqueue fd ref (for kqueue mode only)
57 $_io, # IO::Handle for Epoll
58 @ToClose, # sockets to close when event loop is done
60 $PostLoopCallback, # subref to call at the end of each loop, if defined (global)
62 $LoopTimeout, # timeout of event loop in milliseconds
63 $DoneInit, # if we've done the one-time module init yet
67 # this may be set to zero with old kernels
68 our $EPOLLEXCLUSIVE = EPOLLEXCLUSIVE;
71 #####################################################################
72 ### C L A S S M E T H O D S
73 #####################################################################
75 =head2 C<< CLASS->Reset() >>
83 $LoopTimeout = -1; # no timeout by default
86 $PostLoopCallback = undef;
89 # NOTE kqueue is close-on-fork, and we don't account for it, yet
90 # OTOH, we (public-inbox) don't need this sub outside of tests...
91 POSIX::close($$KQueue) if !$_io && $KQueue && $$KQueue >= 0;
94 $_io = undef; # close $Epoll
97 *EventLoop = *FirstTimeEventLoop;
100 =head2 C<< CLASS->SetLoopTimeout( $timeout ) >>
102 Set the loop timeout for the event loop to some value in milliseconds.
104 A timeout of 0 (zero) means poll forever. A timeout of -1 means poll and return
109 return $LoopTimeout = $_[1] + 0;
112 =head2 C<< CLASS->DebugMsg( $format, @args ) >>
114 Print the debugging message specified by the C<sprintf>-style I<format> and
119 my ( $class, $fmt, @args ) = @_;
121 printf STDERR ">>> $fmt\n", @args;
124 =head2 C<< CLASS->AddTimer( $seconds, $coderef ) >>
126 Add a timer to occur $seconds from now. $seconds may be fractional, but timers
127 are not guaranteed to fire at the exact time you ask for.
129 Returns a timer object which you can call C<< $timer->cancel >> on if you need to.
134 my ($secs, $coderef) = @_;
136 my $fire_time = Time::HiRes::time() + $secs;
138 my $timer = bless [$fire_time, $coderef], "PublicInbox::DS::Timer";
140 if (!@Timers || $fire_time >= $Timers[-1][0]) {
141 push @Timers, $timer;
145 # Now, where do we insert? (NOTE: this appears slow, algorithm-wise,
146 # but it was compared against calendar queues, heaps, naive push/sort,
147 # and a bunch of other versions, and found to be fastest with a large
148 # variety of datasets.)
149 for (my $i = 0; $i < @Timers; $i++) {
150 if ($Timers[$i][0] > $fire_time) {
151 splice(@Timers, $i, 0, $timer);
156 die "Shouldn't get here.";
159 # keeping this around in case we support other FD types for now,
160 # epoll_create1(EPOLL_CLOEXEC) requires Linux 2.6.27+...
161 sub set_cloexec ($) {
164 $_io = IO::Handle->new_from_fd($fd, 'r+') or return;
165 defined(my $fl = fcntl($_io, F_GETFD, 0)) or return;
166 fcntl($_io, F_SETFD, $fl | FD_CLOEXEC);
175 $KQueue = IO::KQueue->new();
176 $HaveKQueue = defined $KQueue;
178 *EventLoop = *KQueueEventLoop;
181 elsif (PublicInbox::Syscall::epoll_defined()) {
182 $Epoll = eval { epoll_create(1024); };
183 $HaveEpoll = defined $Epoll && $Epoll >= 0;
186 *EventLoop = *EpollEventLoop;
190 if (!$HaveEpoll && !$HaveKQueue) {
192 *EventLoop = *PollEventLoop;
196 =head2 C<< CLASS->EventLoop() >>
198 Start processing IO events. In most daemon programs this never exits. See
199 C<PostLoopCallback> below for how to exit the loop.
202 sub FirstTimeEventLoop {
208 EpollEventLoop($class);
209 } elsif ($HaveKQueue) {
210 KQueueEventLoop($class);
212 PollEventLoop($class);
216 # runs timers and returns milliseconds for next one, or next event loop
218 return $LoopTimeout unless @Timers;
220 my $now = Time::HiRes::time();
223 while (@Timers && $Timers[0][0] <= $now) {
224 my $to_run = shift(@Timers);
225 $to_run->[1]->($now) if $to_run->[1];
228 return $LoopTimeout unless @Timers;
230 # convert time to an even number of milliseconds, adding 1
231 # extra, otherwise floating point fun can occur and we'll
232 # call RunTimers like 20-30 times, each returning a timeout
233 # of 0.0000212 seconds
234 my $timeout = int(($Timers[0][0] - $now) * 1000) + 1;
236 # -1 is an infinite timeout, so prefer a real timeout
237 return $timeout if $LoopTimeout == -1;
239 # otherwise pick the lower of our regular timeout and time until
241 return $LoopTimeout if $LoopTimeout < $timeout;
245 ### The epoll-based event loop. Gets installed as EventLoop if IO::Epoll loads
253 my $timeout = RunTimers();
255 # get up to 1000 events
256 my $evcount = epoll_wait($Epoll, 1000, $timeout, \@events);
257 for ($i=0; $i<$evcount; $i++) {
258 my $ev = $events[$i];
260 # it's possible epoll_wait returned many events, including some at the end
261 # that ones in the front triggered unregister-interest actions. if we
262 # can't find the %sock entry, it's because we're no longer interested
264 my PublicInbox::DS $pob = $DescriptorMap{$ev->[0]};
266 my $state = $ev->[1];
268 DebugLevel >= 1 && $class->DebugMsg("Event: fd=%d (%s), state=%d \@ %s\n",
269 $ev->[0], ref($pob), $ev->[1], time);
271 # standard non-profiling codepat
272 $pob->event_read if $state & EPOLLIN && ! $pob->{closed};
273 $pob->event_write if $state & EPOLLOUT && ! $pob->{closed};
274 if ($state & (EPOLLERR|EPOLLHUP)) {
275 $pob->event_err if $state & EPOLLERR && ! $pob->{closed};
276 $pob->event_hup if $state & EPOLLHUP && ! $pob->{closed};
279 return unless PostEventLoop();
284 ### The fallback IO::Poll-based event loop. Gets installed as EventLoop if
285 ### IO::Epoll fails to load.
289 my PublicInbox::DS $pob;
292 my $timeout = RunTimers();
294 # the following sets up @poll as a series of ($poll,$event_mask)
295 # items, then uses IO::Poll::_poll, implemented in XS, which
296 # modifies the array in place with the even elements being
297 # replaced with the event masks that occured.
299 while ( my ($fd, $sock) = each %DescriptorMap ) {
300 push @poll, $fd, $sock->{event_watch};
303 # if nothing to poll, either end immediately (if no timeout)
304 # or just keep calling the callback
306 select undef, undef, undef, ($timeout / 1000);
307 return unless PostEventLoop();
311 my $count = IO::Poll::_poll($timeout, @poll);
312 unless ($count >= 0) {
313 return unless PostEventLoop();
317 # Fetch handles with read events
319 my ($fd, $state) = splice(@poll, 0, 2);
322 $pob = $DescriptorMap{$fd};
324 $pob->event_read if $state & POLLIN && ! $pob->{closed};
325 $pob->event_write if $state & POLLOUT && ! $pob->{closed};
326 $pob->event_err if $state & POLLERR && ! $pob->{closed};
327 $pob->event_hup if $state & POLLHUP && ! $pob->{closed};
330 return unless PostEventLoop();
336 ### The kqueue-based event loop. Gets installed as EventLoop if IO::KQueue works
338 sub KQueueEventLoop {
342 my $timeout = RunTimers();
343 my @ret = eval { $KQueue->kevent($timeout) };
345 # workaround https://rt.cpan.org/Ticket/Display.html?id=116615
346 if ($err =~ /Interrupted system call/) {
353 foreach my $kev (@ret) {
354 my ($fd, $filter, $flags, $fflags) = @$kev;
355 my PublicInbox::DS $pob = $DescriptorMap{$fd};
357 DebugLevel >= 1 && $class->DebugMsg("Event: fd=%d (%s), flags=%d \@ %s\n",
358 $fd, ref($pob), $flags, time);
360 $pob->event_read if $filter == IO::KQueue::EVFILT_READ() && !$pob->{closed};
361 $pob->event_write if $filter == IO::KQueue::EVFILT_WRITE() && !$pob->{closed};
362 if ($flags == IO::KQueue::EV_EOF() && !$pob->{closed}) {
370 return unless PostEventLoop();
376 =head2 C<< CLASS->SetPostLoopCallback( CODEREF ) >>
378 Sets post loop callback function. Pass a subref and it will be
379 called every time the event loop finishes.
381 Return 1 (or any true value) from the sub to make the loop continue, 0 or false
384 The callback function will be passed two parameters: \%DescriptorMap
387 sub SetPostLoopCallback {
388 my ($class, $ref) = @_;
391 $PostLoopCallback = (defined $ref && ref $ref eq 'CODE') ? $ref : undef;
394 # Internal function: run the post-event callback, send read events
395 # for pushed-back data, and close pending connections. returns 1
396 # if event loop should continue, or 0 to shut it all down.
398 # now we can close sockets that wanted to close during our event processing.
399 # (we didn't want to close them during the loop, as we didn't want fd numbers
400 # being reused and confused during the event loop)
401 while (my $sock = shift @ToClose) {
402 my $fd = fileno($sock);
404 # close the socket. (not a PublicInbox::DS close)
407 # and now we can finally remove the fd from the map. see
408 # comment above in _cleanup.
409 delete $DescriptorMap{$fd};
413 # by default we keep running, unless a postloop callback (either per-object
414 # or global) cancels it
415 my $keep_running = 1;
417 # now we're at the very end, call callback if defined
418 if (defined $PostLoopCallback) {
419 $keep_running &&= $PostLoopCallback->(\%DescriptorMap);
422 return $keep_running;
425 #####################################################################
426 ### PublicInbox::DS-the-object code
427 #####################################################################
429 =head2 OBJECT METHODS
431 =head2 C<< CLASS->new( $socket ) >>
433 Create a new PublicInbox::DS subclass object for the given I<socket> which will
434 react to events on it during the C<EventLoop>.
436 This is normally (always?) called from your subclass via:
438 $class->SUPER::new($socket);
442 my ($self, $sock, $exclusive) = @_;
443 $self = fields::new($self) unless ref $self;
445 $self->{sock} = $sock;
446 my $fd = fileno($sock);
448 Carp::cluck("undef sock and/or fd in PublicInbox::DS->new. sock=" . ($sock || "") . ", fd=" . ($fd || ""))
452 $self->{write_buf} = [];
453 $self->{write_buf_offset} = 0;
454 $self->{write_buf_size} = 0;
457 my $ev = $self->{event_watch} = POLLERR|POLLHUP|POLLNVAL;
463 $ev = $self->{event_watch} = EPOLLIN|EPOLLERR|EPOLLHUP|$EPOLLEXCLUSIVE;
466 if (epoll_ctl($Epoll, EPOLL_CTL_ADD, $fd, $ev)) {
467 if ($!{EINVAL} && ($ev & $EPOLLEXCLUSIVE)) {
468 $EPOLLEXCLUSIVE = 0; # old kernel
469 $ev = $self->{event_watch} = EPOLLIN|EPOLLERR|EPOLLHUP;
472 die "couldn't add epoll watch for $fd: $!\n";
475 elsif ($HaveKQueue) {
476 # Add them to the queue but disabled for now
477 $KQueue->EV_SET($fd, IO::KQueue::EVFILT_READ(),
478 IO::KQueue::EV_ADD() | IO::KQueue::EV_DISABLE());
479 $KQueue->EV_SET($fd, IO::KQueue::EVFILT_WRITE(),
480 IO::KQueue::EV_ADD() | IO::KQueue::EV_DISABLE());
483 Carp::cluck("PublicInbox::DS::new blowing away existing descriptor map for fd=$fd ($DescriptorMap{$fd})")
484 if $DescriptorMap{$fd};
486 $DescriptorMap{$fd} = $self;
491 #####################################################################
492 ### I N S T A N C E M E T H O D S
493 #####################################################################
495 =head2 C<< $obj->steal_socket() >>
497 Basically returns our socket and makes it so that we don't try to close it,
498 but we do remove it from epoll handlers. THIS CLOSES $self. It is the same
499 thing as calling close, except it gives you the socket to use.
503 my PublicInbox::DS $self = $_[0];
504 return if $self->{closed};
506 # cleanup does most of the work of closing this socket
509 # now undef our internal sock and fd structures so we don't use them
510 my $sock = $self->{sock};
511 $self->{sock} = undef;
515 =head2 C<< $obj->close( [$reason] ) >>
517 Close the socket. The I<reason> argument will be used in debugging messages.
521 my PublicInbox::DS $self = $_[0];
522 return if $self->{closed};
524 # print out debugging info for this close
526 my ($pkg, $filename, $line) = caller;
527 my $reason = $_[1] || "";
528 warn "Closing \#$self->{fd} due to $pkg/$filename/$line ($reason)\n";
531 # this does most of the work of closing us
534 # defer closing the actual socket until the event loop is done
535 # processing this round of events. (otherwise we might reuse fds)
537 push @ToClose, $self->{sock};
538 $self->{sock} = undef;
544 ### METHOD: _cleanup()
545 ### Called by our closers so we can clean internal data structures.
547 my PublicInbox::DS $self = $_[0];
549 # we're effectively closed; we have no fd and sock when we leave here
552 # we need to flush our write buffer, as there may
553 # be self-referential closures (sub { $client->close })
554 # preventing the object from being destroyed
555 $self->{write_buf} = [];
557 # if we're using epoll, we have to remove this from our epoll fd so we stop getting
558 # notifications about it
559 if ($HaveEpoll && $self->{fd}) {
560 if (epoll_ctl($Epoll, EPOLL_CTL_DEL, $self->{fd}, $self->{event_watch}) != 0) {
561 # dump_error prints a backtrace so we can try to figure out why this happened
562 $self->dump_error("epoll_ctl(): failure deleting fd=$self->{fd} during _cleanup(); $! (" . ($!+0) . ")");
566 # we explicitly don't delete from DescriptorMap here until we
567 # actually close the socket, as we might be in the middle of
568 # processing an epoll_wait/etc that returned hundreds of fds, one
569 # of which is not yet processed and is what we're closing. if we
570 # keep it in DescriptorMap, then the event harnesses can just
571 # looked at $pob->{closed} and ignore it. but if it's an
572 # un-accounted for fd, then it (understandably) freak out a bit
573 # and emit warnings, thinking their state got off.
575 # and finally get rid of our fd so we can't use it anywhere else
579 =head2 C<< $obj->sock() >>
581 Returns the underlying IO::Handle for the object.
585 my PublicInbox::DS $self = shift;
586 return $self->{sock};
589 =head2 C<< $obj->write( $data ) >>
591 Write the specified data to the underlying handle. I<data> may be scalar,
592 scalar ref, code ref (to run when there), or undef just to kick-start.
593 Returns 1 if writes all went through, or 0 if there are writes in queue. If
594 it returns 1, caller should stop waiting for 'writable' events)
598 my PublicInbox::DS $self;
602 # nobody should be writing to closed sockets, but caller code can
603 # do two writes within an event, have the first fail and
604 # disconnect the other side (whose destructor then closes the
605 # calling object, but it's still in a method), and then the
606 # now-dead object does its second write. that is this case. we
607 # just lie and say it worked. it'll be dead soon and won't be
609 return 1 if $self->{closed};
613 # just queue data if there's already a wait
617 $bref = ref $data ? $data : \$data;
618 if ($self->{write_buf_size}) {
619 push @{$self->{write_buf}}, $bref;
620 $self->{write_buf_size} += ref $bref eq "SCALAR" ? length($$bref) : 1;
624 # this flag says we're bypassing the queue system, knowing we're the
625 # only outstanding write, and hoping we don't ever need to use it.
626 # if so later, though, we'll need to queue
632 return 1 unless $bref ||= $self->{write_buf}[0];
636 $len = length($$bref); # this will die if $bref is a code ref, caught below
639 if (UNIVERSAL::isa($bref, "CODE")) {
640 unless ($need_queue) {
641 $self->{write_buf_size}--; # code refs are worth 1
642 shift @{$self->{write_buf}};
646 # code refs are just run and never get reenqueued
647 # (they're one-shot), so turn off the flag indicating the
648 # outstanding data needs queueing.
654 die "Write error: $@ <$bref>";
657 my $to_write = $len - $self->{write_buf_offset};
658 my $written = syswrite($self->{sock}, $$bref, $to_write,
659 $self->{write_buf_offset});
661 if (! defined $written) {
663 return $self->close("EPIPE");
664 } elsif ($! == EAGAIN) {
665 # since connection has stuff to write, it should now be
666 # interested in pending writes:
668 push @{$self->{write_buf}}, $bref;
669 $self->{write_buf_size} += $len;
671 $self->watch_write(1);
673 } elsif ($! == ECONNRESET) {
674 return $self->close("ECONNRESET");
677 DebugLevel >= 1 && $self->debugmsg("Closing connection ($self) due to write error: $!\n");
679 return $self->close("write_error");
680 } elsif ($written != $to_write) {
681 DebugLevel >= 2 && $self->debugmsg("Wrote PARTIAL %d bytes to %d",
682 $written, $self->{fd});
684 push @{$self->{write_buf}}, $bref;
685 $self->{write_buf_size} += $len;
687 # since connection has stuff to write, it should now be
688 # interested in pending writes:
689 $self->{write_buf_offset} += $written;
690 $self->{write_buf_size} -= $written;
691 $self->on_incomplete_write;
693 } elsif ($written == $to_write) {
694 DebugLevel >= 2 && $self->debugmsg("Wrote ALL %d bytes to %d (nq=%d)",
695 $written, $self->{fd}, $need_queue);
696 $self->{write_buf_offset} = 0;
697 $self->watch_write(0);
699 # this was our only write, so we can return immediately
700 # since we avoided incrementing the buffer size or
701 # putting it in the buffer. we also know there
702 # can't be anything else to write.
703 return 1 if $need_queue;
705 $self->{write_buf_size} -= $written;
706 shift @{$self->{write_buf}};
713 sub on_incomplete_write {
714 my PublicInbox::DS $self = shift;
715 $self->watch_write(1);
718 =head2 C<< $obj->read( $bytecount ) >>
720 Read at most I<bytecount> bytes from the underlying handle; returns scalar
721 ref on read, or undef on connection closed.
725 my PublicInbox::DS $self = shift;
726 return if $self->{closed};
729 my $sock = $self->{sock};
731 # if this is too high, perl quits(!!). reports on mailing lists
732 # don't seem to point to a universal answer. 5MB worked for some,
733 # crashed for others. 1MB works for more people. let's go with 1MB
735 my $req_bytes = $bytes > 1048576 ? 1048576 : $bytes;
737 my $res = sysread($sock, $buf, $req_bytes, 0);
738 DebugLevel >= 2 && $self->debugmsg("sysread = %d; \$! = %d", $res, $!);
740 if (! $res && $! != EWOULDBLOCK) {
741 # catches 0=conn closed or undef=error
742 DebugLevel >= 2 && $self->debugmsg("Fd \#%d read hit the end of the road.", $self->{fd});
749 =head2 (VIRTUAL) C<< $obj->event_read() >>
751 Readable event handler. Concrete deriviatives of PublicInbox::DS should
752 provide an implementation of this. The default implementation will die if
756 sub event_read { die "Base class event_read called for $_[0]\n"; }
758 =head2 (VIRTUAL) C<< $obj->event_err() >>
760 Error event handler. Concrete deriviatives of PublicInbox::DS should
761 provide an implementation of this. The default implementation will die if
765 sub event_err { die "Base class event_err called for $_[0]\n"; }
767 =head2 (VIRTUAL) C<< $obj->event_hup() >>
769 'Hangup' event handler. Concrete deriviatives of PublicInbox::DS should
770 provide an implementation of this. The default implementation will die if
774 sub event_hup { die "Base class event_hup called for $_[0]\n"; }
776 =head2 C<< $obj->event_write() >>
778 Writable event handler. Concrete deriviatives of PublicInbox::DS may wish to
779 provide an implementation of this. The default implementation calls
780 C<write()> with an C<undef>.
788 =head2 C<< $obj->watch_read( $boolean ) >>
790 Turn 'readable' event notification on or off.
794 my PublicInbox::DS $self = shift;
795 return if $self->{closed} || !$self->{sock};
798 my $event = $self->{event_watch};
800 $event &= ~POLLIN if ! $val;
801 $event |= POLLIN if $val;
803 # If it changed, set it
804 if ($event != $self->{event_watch}) {
806 $KQueue->EV_SET($self->{fd}, IO::KQueue::EVFILT_READ(),
807 $val ? IO::KQueue::EV_ENABLE() : IO::KQueue::EV_DISABLE());
810 epoll_ctl($Epoll, EPOLL_CTL_MOD, $self->{fd}, $event)
811 and $self->dump_error("couldn't modify epoll settings for $self->{fd} " .
812 "from $self->{event_watch} -> $event: $! (" . ($!+0) . ")");
814 $self->{event_watch} = $event;
818 =head2 C<< $obj->watch_write( $boolean ) >>
820 Turn 'writable' event notification on or off.
824 my PublicInbox::DS $self = shift;
825 return if $self->{closed} || !$self->{sock};
828 my $event = $self->{event_watch};
830 $event &= ~POLLOUT if ! $val;
831 $event |= POLLOUT if $val;
833 # If it changed, set it
834 if ($event != $self->{event_watch}) {
836 $KQueue->EV_SET($self->{fd}, IO::KQueue::EVFILT_WRITE(),
837 $val ? IO::KQueue::EV_ENABLE() : IO::KQueue::EV_DISABLE());
840 epoll_ctl($Epoll, EPOLL_CTL_MOD, $self->{fd}, $event)
841 and $self->dump_error("couldn't modify epoll settings for $self->{fd} " .
842 "from $self->{event_watch} -> $event: $! (" . ($!+0) . ")");
844 $self->{event_watch} = $event;
848 =head2 C<< $obj->dump_error( $message ) >>
850 Prints to STDERR a backtrace with information about this socket and what lead
851 up to the dump_error call.
857 while (my ($file, $line, $sub) = (caller($i++))[1..3]) {
858 push @list, "\t$file:$line called $sub\n";
861 warn "ERROR: $_[1]\n" .
862 "\t$_[0] = " . $_[0]->as_string . "\n" .
866 =head2 C<< $obj->debugmsg( $format, @args ) >>
868 Print the debugging message specified by the C<sprintf>-style I<format> and
873 my ( $self, $fmt, @args ) = @_;
874 confess "Not an object" unless ref $self;
877 printf STDERR ">>> $fmt\n", @args;
880 =head2 C<< $obj->as_string() >>
882 Returns a string describing this socket.
886 my PublicInbox::DS $self = shift;
887 my $rw = "(" . ($self->{event_watch} & POLLIN ? 'R' : '') .
888 ($self->{event_watch} & POLLOUT ? 'W' : '') . ")";
889 my $ret = ref($self) . "$rw: " . ($self->{closed} ? "closed" : "open");
893 package PublicInbox::DS::Timer;
894 # [$abs_float_firetime, $coderef];
901 =head1 AUTHORS (Danga::Socket)
903 Brad Fitzpatrick <brad@danga.com> - author
905 Michael Granger <ged@danga.com> - docs, testing
907 Mark Smith <junior@danga.com> - contributor, heavy user, testing
909 Matt Sergeant <matt@sergeant.org> - kqueue support, docs, timers, other bits