]> Sergey Matveev's repositories - public-inbox.git/blob - lib/PublicInbox/DS.pm
triewyde: ficks soem speling errrors
[public-inbox.git] / lib / PublicInbox / DS.pm
1 # This library is free software; you can redistribute it and/or modify
2 # it under the same terms as Perl itself.
3 #
4 # This license differs from the rest of public-inbox
5 #
6 # This is a fork of the unmaintained Danga::Socket (1.61) with
7 # significant changes.  See Documentation/technical/ds.txt in our
8 # source for details.
9 #
10 # Do not expect this to be a stable API like Danga::Socket,
11 # but it will evolve to suite our needs and to take advantage of
12 # newer Linux and *BSD features.
13 # Bugs encountered were reported to bug-Danga-Socket@rt.cpan.org,
14 # fixed in Danga::Socket 1.62 and visible at:
15 # https://rt.cpan.org/Public/Dist/Display.html?Name=Danga-Socket
16 package PublicInbox::DS;
17 use strict;
18 use bytes;
19 use POSIX qw(WNOHANG);
20 use IO::Handle qw();
21 use Fcntl qw(SEEK_SET :DEFAULT O_APPEND);
22 use Time::HiRes qw(clock_gettime CLOCK_MONOTONIC);
23 use parent qw(Exporter);
24 our @EXPORT_OK = qw(now msg_more);
25 use warnings;
26 use 5.010_001;
27 use Scalar::Util qw(blessed);
28
29 use PublicInbox::Syscall qw(:epoll);
30 use PublicInbox::Tmpfile;
31
32 use fields ('sock',              # underlying socket
33             'rbuf',              # scalarref, usually undef
34             'wbuf', # arrayref of coderefs or tmpio (autovivified))
35                     # (tmpio = [ GLOB, offset, [ length ] ])
36             );
37
38 use Errno qw(EAGAIN EINVAL);
39 use Carp qw(confess carp);
40
41 my $nextq; # queue for next_tick
42 my $wait_pids; # list of [ pid, callback, callback_arg ]
43 my $later_queue; # list of callbacks to run at some later interval
44 my $EXPMAP; # fd -> idle_time
45 our $EXPTIME = 180; # 3 minutes
46 my ($later_timer, $reap_timer, $exp_timer);
47 my $ToClose; # sockets to close when event loop is done
48 our (
49      %DescriptorMap,             # fd (num) -> PublicInbox::DS object
50      $Epoll,                     # Global epoll fd (or DSKQXS ref)
51      $_io,                       # IO::Handle for Epoll
52
53      $PostLoopCallback,          # subref to call at the end of each loop, if defined (global)
54
55      $LoopTimeout,               # timeout of event loop in milliseconds
56      $DoneInit,                  # if we've done the one-time module init yet
57      @Timers,                    # timers
58      $in_loop,
59      );
60
61 Reset();
62
63 #####################################################################
64 ### C L A S S   M E T H O D S
65 #####################################################################
66
67 =head2 C<< CLASS->Reset() >>
68
69 Reset all state
70
71 =cut
72 sub Reset {
73     %DescriptorMap = ();
74     $wait_pids = $later_queue = undef;
75     $EXPMAP = {};
76     $nextq = $ToClose = $reap_timer = $later_timer = $exp_timer = undef;
77     $LoopTimeout = -1;  # no timeout by default
78     @Timers = ();
79
80     $PostLoopCallback = undef;
81     $DoneInit = 0;
82
83     $_io = undef; # closes real $Epoll FD
84     $Epoll = undef; # may call DSKQXS::DESTROY
85
86     *EventLoop = *FirstTimeEventLoop;
87 }
88
89 =head2 C<< CLASS->SetLoopTimeout( $timeout ) >>
90
91 Set the loop timeout for the event loop to some value in milliseconds.
92
93 A timeout of 0 (zero) means poll forever. A timeout of -1 means poll and return
94 immediately.
95
96 =cut
97 sub SetLoopTimeout {
98     return $LoopTimeout = $_[1] + 0;
99 }
100
101 =head2 C<< PublicInbox::DS::add_timer( $seconds, $coderef ) >>
102
103 Add a timer to occur $seconds from now. $seconds may be fractional, but timers
104 are not guaranteed to fire at the exact time you ask for.
105
106 =cut
107 sub add_timer ($$) {
108     my ($secs, $coderef) = @_;
109
110     my $fire_time = now() + $secs;
111
112     my $timer = [$fire_time, $coderef];
113
114     if (!@Timers || $fire_time >= $Timers[-1][0]) {
115         push @Timers, $timer;
116         return $timer;
117     }
118
119     # Now, where do we insert?  (NOTE: this appears slow, algorithm-wise,
120     # but it was compared against calendar queues, heaps, naive push/sort,
121     # and a bunch of other versions, and found to be fastest with a large
122     # variety of datasets.)
123     for (my $i = 0; $i < @Timers; $i++) {
124         if ($Timers[$i][0] > $fire_time) {
125             splice(@Timers, $i, 0, $timer);
126             return $timer;
127         }
128     }
129
130     die "Shouldn't get here.";
131 }
132
133 # keeping this around in case we support other FD types for now,
134 # epoll_create1(EPOLL_CLOEXEC) requires Linux 2.6.27+...
135 sub set_cloexec ($) {
136     my ($fd) = @_;
137
138     $_io = IO::Handle->new_from_fd($fd, 'r+') or return;
139     defined(my $fl = fcntl($_io, F_GETFD, 0)) or return;
140     fcntl($_io, F_SETFD, $fl | FD_CLOEXEC);
141 }
142
143 sub _InitPoller
144 {
145     return if $DoneInit;
146     $DoneInit = 1;
147
148     if (PublicInbox::Syscall::epoll_defined())  {
149         $Epoll = epoll_create();
150         set_cloexec($Epoll) if (defined($Epoll) && $Epoll >= 0);
151     } else {
152         my $cls;
153         for (qw(DSKQXS DSPoll)) {
154             $cls = "PublicInbox::$_";
155             last if eval "require $cls";
156         }
157         $cls->import(qw(epoll_ctl epoll_wait));
158         $Epoll = $cls->new;
159     }
160     *EventLoop = *EpollEventLoop;
161 }
162
163 =head2 C<< CLASS->EventLoop() >>
164
165 Start processing IO events. In most daemon programs this never exits. See
166 C<PostLoopCallback> below for how to exit the loop.
167
168 =cut
169 sub FirstTimeEventLoop {
170     my $class = shift;
171
172     _InitPoller();
173
174     EventLoop($class);
175 }
176
177 sub now () { clock_gettime(CLOCK_MONOTONIC) }
178
179 sub next_tick () {
180     my $q = $nextq or return;
181     $nextq = undef;
182     for (@$q) {
183         # we avoid "ref" on blessed refs to workaround a Perl 5.16.3 leak:
184         # https://rt.perl.org/Public/Bug/Display.html?id=114340
185         if (blessed($_)) {
186             $_->event_step;
187         } else {
188             $_->();
189         }
190     }
191 }
192
193 # runs timers and returns milliseconds for next one, or next event loop
194 sub RunTimers {
195     next_tick();
196
197     return (($nextq || $ToClose) ? 0 : $LoopTimeout) unless @Timers;
198
199     my $now = now();
200
201     # Run expired timers
202     while (@Timers && $Timers[0][0] <= $now) {
203         my $to_run = shift(@Timers);
204         $to_run->[1]->($now) if $to_run->[1];
205     }
206
207     # timers may enqueue into nextq:
208     return 0 if ($nextq || $ToClose);
209
210     return $LoopTimeout unless @Timers;
211
212     # convert time to an even number of milliseconds, adding 1
213     # extra, otherwise floating point fun can occur and we'll
214     # call RunTimers like 20-30 times, each returning a timeout
215     # of 0.0000212 seconds
216     my $timeout = int(($Timers[0][0] - $now) * 1000) + 1;
217
218     # -1 is an infinite timeout, so prefer a real timeout
219     return $timeout     if $LoopTimeout == -1;
220
221     # otherwise pick the lower of our regular timeout and time until
222     # the next timer
223     return $LoopTimeout if $LoopTimeout < $timeout;
224     return $timeout;
225 }
226
227 # We can't use waitpid(-1) safely here since it can hit ``, system(),
228 # and other things.  So we scan the $wait_pids list, which is hopefully
229 # not too big.  We keep $wait_pids small by not calling dwaitpid()
230 # until we've hit EOF when reading the stdout of the child.
231 sub reap_pids {
232     my $tmp = $wait_pids or return;
233     $wait_pids = $reap_timer = undef;
234     foreach my $ary (@$tmp) {
235         my ($pid, $cb, $arg) = @$ary;
236         my $ret = waitpid($pid, WNOHANG);
237         if ($ret == 0) {
238             push @$wait_pids, $ary; # autovivifies @$wait_pids
239         } elsif ($cb) {
240             eval { $cb->($arg, $pid) };
241         }
242     }
243     # we may not be done, yet, and could've missed/masked a SIGCHLD:
244     $reap_timer = add_timer(1, \&reap_pids) if $wait_pids;
245 }
246
247 # reentrant SIGCHLD handler (since reap_pids is not reentrant)
248 sub enqueue_reap ($) { push @$nextq, \&reap_pids }; # autovivifies
249
250 sub in_loop () { $in_loop }
251
252 # Internal function: run the post-event callback, send read events
253 # for pushed-back data, and close pending connections.  returns 1
254 # if event loop should continue, or 0 to shut it all down.
255 sub PostEventLoop () {
256         # now we can close sockets that wanted to close during our event
257         # processing.  (we didn't want to close them during the loop, as we
258         # didn't want fd numbers being reused and confused during the event
259         # loop)
260         if (my $close_now = $ToClose) {
261                 $ToClose = undef; # will be autovivified on push
262                 @$close_now = map { fileno($_) } @$close_now;
263
264                 # order matters, destroy expiry times, first:
265                 delete @$EXPMAP{@$close_now};
266
267                 # ->DESTROY methods may populate ToClose
268                 delete @DescriptorMap{@$close_now};
269         }
270
271         # by default we keep running, unless a postloop callback cancels it
272         $PostLoopCallback ? $PostLoopCallback->(\%DescriptorMap) : 1;
273 }
274
275 sub EpollEventLoop {
276     local $in_loop = 1;
277     do {
278         my @events;
279         my $i;
280         my $timeout = RunTimers();
281
282         # get up to 1000 events
283         my $evcount = epoll_wait($Epoll, 1000, $timeout, \@events);
284         for ($i=0; $i<$evcount; $i++) {
285             # it's possible epoll_wait returned many events, including some at the end
286             # that ones in the front triggered unregister-interest actions.  if we
287             # can't find the %sock entry, it's because we're no longer interested
288             # in that event.
289             $DescriptorMap{$events[$i]->[0]}->event_step;
290         }
291     } while (PostEventLoop());
292     _run_later();
293 }
294
295 =head2 C<< CLASS->SetPostLoopCallback( CODEREF ) >>
296
297 Sets post loop callback function.  Pass a subref and it will be
298 called every time the event loop finishes.
299
300 Return 1 (or any true value) from the sub to make the loop continue, 0 or false
301 and it will exit.
302
303 The callback function will be passed two parameters: \%DescriptorMap
304
305 =cut
306 sub SetPostLoopCallback {
307     my ($class, $ref) = @_;
308
309     # global callback
310     $PostLoopCallback = (defined $ref && ref $ref eq 'CODE') ? $ref : undef;
311 }
312
313 #####################################################################
314 ### PublicInbox::DS-the-object code
315 #####################################################################
316
317 =head2 OBJECT METHODS
318
319 =head2 C<< CLASS->new( $socket ) >>
320
321 Create a new PublicInbox::DS subclass object for the given I<socket> which will
322 react to events on it during the C<EventLoop>.
323
324 This is normally (always?) called from your subclass via:
325
326   $class->SUPER::new($socket);
327
328 =cut
329 sub new {
330     my ($self, $sock, $ev) = @_;
331     $self = fields::new($self) unless ref $self;
332
333     $self->{sock} = $sock;
334     my $fd = fileno($sock);
335
336     _InitPoller();
337
338     if (epoll_ctl($Epoll, EPOLL_CTL_ADD, $fd, $ev)) {
339         if ($! == EINVAL && ($ev & EPOLLEXCLUSIVE)) {
340             $ev &= ~EPOLLEXCLUSIVE;
341             goto retry;
342         }
343         die "couldn't add epoll watch for $fd: $!\n";
344     }
345     confess("DescriptorMap{$fd} defined ($DescriptorMap{$fd})")
346         if defined($DescriptorMap{$fd});
347
348     $DescriptorMap{$fd} = $self;
349 }
350
351
352 #####################################################################
353 ### I N S T A N C E   M E T H O D S
354 #####################################################################
355
356 sub requeue ($) { push @$nextq, $_[0] } # autovivifies
357
358 =head2 C<< $obj->close >>
359
360 Close the socket.
361
362 =cut
363 sub close {
364     my ($self) = @_;
365     my $sock = delete $self->{sock} or return;
366
367     # we need to flush our write buffer, as there may
368     # be self-referential closures (sub { $client->close })
369     # preventing the object from being destroyed
370     delete $self->{wbuf};
371
372     # if we're using epoll, we have to remove this from our epoll fd so we stop getting
373     # notifications about it
374     my $fd = fileno($sock);
375     epoll_ctl($Epoll, EPOLL_CTL_DEL, $fd, 0) and
376         confess("EPOLL_CTL_DEL: $!");
377
378     # we explicitly don't delete from DescriptorMap here until we
379     # actually close the socket, as we might be in the middle of
380     # processing an epoll_wait/etc that returned hundreds of fds, one
381     # of which is not yet processed and is what we're closing.  if we
382     # keep it in DescriptorMap, then the event harnesses can just
383     # looked at $pob->{sock} == undef and ignore it.  but if it's an
384     # un-accounted for fd, then it (understandably) freak out a bit
385     # and emit warnings, thinking their state got off.
386
387     # defer closing the actual socket until the event loop is done
388     # processing this round of events.  (otherwise we might reuse fds)
389     push @$ToClose, $sock; # autovivifies $ToClose
390
391     return 0;
392 }
393
394 # portable, non-thread-safe sendfile emulation (no pread, yet)
395 sub send_tmpio ($$) {
396     my ($sock, $tmpio) = @_;
397
398     sysseek($tmpio->[0], $tmpio->[1], SEEK_SET) or return;
399     my $n = $tmpio->[2] // 65536;
400     $n = 65536 if $n > 65536;
401     defined(my $to_write = sysread($tmpio->[0], my $buf, $n)) or return;
402     my $written = 0;
403     while ($to_write > 0) {
404         if (defined(my $w = syswrite($sock, $buf, $to_write, $written))) {
405             $written += $w;
406             $to_write -= $w;
407         } else {
408             return if $written == 0;
409             last;
410         }
411     }
412     $tmpio->[1] += $written; # offset
413     $tmpio->[2] -= $written if defined($tmpio->[2]); # length
414     $written;
415 }
416
417 sub epbit ($$) { # (sock, default)
418     ref($_[0]) eq 'IO::Socket::SSL' ? PublicInbox::TLS::epollbit() : $_[1];
419 }
420
421 # returns 1 if done, 0 if incomplete
422 sub flush_write ($) {
423     my ($self) = @_;
424     my $wbuf = $self->{wbuf} or return 1;
425     my $sock = $self->{sock};
426
427 next_buf:
428     while (my $bref = $wbuf->[0]) {
429         if (ref($bref) ne 'CODE') {
430             while ($sock) {
431                 my $w = send_tmpio($sock, $bref); # bref is tmpio
432                 if (defined $w) {
433                     if ($w == 0) {
434                         shift @$wbuf;
435                         goto next_buf;
436                     }
437                 } elsif ($! == EAGAIN) {
438                     epwait($sock, epbit($sock, EPOLLOUT) | EPOLLONESHOT);
439                     return 0;
440                 } else {
441                     return $self->close;
442                 }
443             }
444         } else { #(ref($bref) eq 'CODE') {
445             shift @$wbuf;
446             my $before = scalar(@$wbuf);
447             $bref->($self);
448
449             # bref may be enqueueing more CODE to call (see accept_tls_step)
450             return 0 if (scalar(@$wbuf) > $before);
451         }
452     } # while @$wbuf
453
454     delete $self->{wbuf};
455     1; # all done
456 }
457
458 sub rbuf_idle ($$) {
459     my ($self, $rbuf) = @_;
460     if ($$rbuf eq '') { # who knows how long till we can read again
461         delete $self->{rbuf};
462     } else {
463         $self->{rbuf} = $rbuf;
464     }
465 }
466
467 sub do_read ($$$;$) {
468     my ($self, $rbuf, $len, $off) = @_;
469     my $r = sysread(my $sock = $self->{sock}, $$rbuf, $len, $off // 0);
470     return ($r == 0 ? $self->close : $r) if defined $r;
471     # common for clients to break connections without warning,
472     # would be too noisy to log here:
473     if ($! == EAGAIN) {
474         epwait($sock, epbit($sock, EPOLLIN) | EPOLLONESHOT);
475         rbuf_idle($self, $rbuf);
476         0;
477     } else {
478         $self->close;
479     }
480 }
481
482 # drop the socket if we hit unrecoverable errors on our system which
483 # require BOFH attention: ENOSPC, EFBIG, EIO, EMFILE, ENFILE...
484 sub drop {
485     my $self = shift;
486     carp(@_);
487     $self->close;
488 }
489
490 # n.b.: use ->write/->read for this buffer to allow compatibility with
491 # PerlIO::mmap or PerlIO::scalar if needed
492 sub tmpio ($$$) {
493     my ($self, $bref, $off) = @_;
494     my $fh = tmpfile('wbuf', $self->{sock}, O_APPEND) or
495         return drop($self, "tmpfile $!");
496     $fh->autoflush(1);
497     my $len = bytes::length($$bref) - $off;
498     $fh->write($$bref, $len, $off) or return drop($self, "write ($len): $!");
499     [ $fh, 0 ] # [1] = offset, [2] = length, not set by us
500 }
501
502 =head2 C<< $obj->write( $data ) >>
503
504 Write the specified data to the underlying handle.  I<data> may be scalar,
505 scalar ref, code ref (to run when there).
506 Returns 1 if writes all went through, or 0 if there are writes in queue. If
507 it returns 1, caller should stop waiting for 'writable' events)
508
509 =cut
510 sub write {
511     my ($self, $data) = @_;
512
513     # nobody should be writing to closed sockets, but caller code can
514     # do two writes within an event, have the first fail and
515     # disconnect the other side (whose destructor then closes the
516     # calling object, but it's still in a method), and then the
517     # now-dead object does its second write.  that is this case.  we
518     # just lie and say it worked.  it'll be dead soon and won't be
519     # hurt by this lie.
520     my $sock = $self->{sock} or return 1;
521     my $ref = ref $data;
522     my $bref = $ref ? $data : \$data;
523     my $wbuf = $self->{wbuf};
524     if ($wbuf && scalar(@$wbuf)) { # already buffering, can't write more...
525         if ($ref eq 'CODE') {
526             push @$wbuf, $bref;
527         } else {
528             my $tmpio = $wbuf->[-1];
529             if ($tmpio && !defined($tmpio->[2])) { # append to tmp file buffer
530                 $tmpio->[0]->print($$bref) or return drop($self, "print: $!");
531             } else {
532                 my $tmpio = tmpio($self, $bref, 0) or return 0;
533                 push @$wbuf, $tmpio;
534             }
535         }
536         return 0;
537     } elsif ($ref eq 'CODE') {
538         $bref->($self);
539         return 1;
540     } else {
541         my $to_write = bytes::length($$bref);
542         my $written = syswrite($sock, $$bref, $to_write);
543
544         if (defined $written) {
545             return 1 if $written == $to_write;
546             requeue($self); # runs: event_step -> flush_write
547         } elsif ($! == EAGAIN) {
548             epwait($sock, epbit($sock, EPOLLOUT) | EPOLLONESHOT);
549             $written = 0;
550         } else {
551             return $self->close;
552         }
553
554         # deal with EAGAIN or partial write:
555         my $tmpio = tmpio($self, $bref, $written) or return 0;
556
557         # wbuf may be an empty array if we're being called inside
558         # ->flush_write via CODE bref:
559         push @{$self->{wbuf}}, $tmpio; # autovivifies
560         return 0;
561     }
562 }
563
564 use constant MSG_MORE => ($^O eq 'linux') ? 0x8000 : 0;
565
566 sub msg_more ($$) {
567     my $self = $_[0];
568     my $sock = $self->{sock} or return 1;
569     my $wbuf = $self->{wbuf};
570
571     if (MSG_MORE && (!defined($wbuf) || !scalar(@$wbuf)) &&
572                 ref($sock) ne 'IO::Socket::SSL') {
573         my $n = send($sock, $_[1], MSG_MORE);
574         if (defined $n) {
575             my $nlen = bytes::length($_[1]) - $n;
576             return 1 if $nlen == 0; # all done!
577             # queue up the unwritten substring:
578             my $tmpio = tmpio($self, \($_[1]), $n) or return 0;
579             push @{$self->{wbuf}}, $tmpio; # autovivifies
580             epwait($sock, EPOLLOUT|EPOLLONESHOT);
581             return 0;
582         }
583     }
584
585     # don't redispatch into NNTPdeflate::write
586     PublicInbox::DS::write($self, \($_[1]));
587 }
588
589 sub epwait ($$) {
590     my ($sock, $ev) = @_;
591     epoll_ctl($Epoll, EPOLL_CTL_MOD, fileno($sock), $ev) and
592         confess("EPOLL_CTL_MOD $!");
593 }
594
595 # return true if complete, false if incomplete (or failure)
596 sub accept_tls_step ($) {
597     my ($self) = @_;
598     my $sock = $self->{sock} or return;
599     return 1 if $sock->accept_SSL;
600     return $self->close if $! != EAGAIN;
601     epwait($sock, PublicInbox::TLS::epollbit() | EPOLLONESHOT);
602     unshift(@{$self->{wbuf}}, \&accept_tls_step); # autovivifies
603     0;
604 }
605
606 # return true if complete, false if incomplete (or failure)
607 sub shutdn_tls_step ($) {
608     my ($self) = @_;
609     my $sock = $self->{sock} or return;
610     return $self->close if $sock->stop_SSL(SSL_fast_shutdown => 1);
611     return $self->close if $! != EAGAIN;
612     epwait($sock, PublicInbox::TLS::epollbit() | EPOLLONESHOT);
613     unshift(@{$self->{wbuf}}, \&shutdn_tls_step); # autovivifies
614     0;
615 }
616
617 # don't bother with shutdown($sock, 2), we don't fork+exec w/o CLOEXEC
618 # or fork w/o exec, so no inadvertent socket sharing
619 sub shutdn ($) {
620     my ($self) = @_;
621     my $sock = $self->{sock} or return;
622     if (ref($sock) eq 'IO::Socket::SSL') {
623         shutdn_tls_step($self);
624     } else {
625         $self->close;
626     }
627 }
628
629 # must be called with eval, PublicInbox::DS may not be loaded (see t/qspawn.t)
630 sub dwaitpid ($$$) {
631         die "Not in EventLoop\n" unless $in_loop;
632         push @$wait_pids, [ @_ ]; # [ $pid, $cb, $arg ]
633
634         # We could've just missed our SIGCHLD, cover it, here:
635         requeue(\&reap_pids);
636 }
637
638 sub _run_later () {
639         my $run = $later_queue or return;
640         $later_timer = $later_queue = undef;
641         $_->() for @$run;
642 }
643
644 sub later ($) {
645         push @$later_queue, $_[0]; # autovivifies @$later_queue
646         $later_timer //= add_timer(60, \&_run_later);
647 }
648
649 sub expire_old () {
650         my $now = now();
651         my $exp = $EXPTIME;
652         my $old = $now - $exp;
653         my %new;
654         while (my ($fd, $idle_at) = each %$EXPMAP) {
655                 if ($idle_at < $old) {
656                         my $ds_obj = $DescriptorMap{$fd};
657                         $new{$fd} = $idle_at if !$ds_obj->shutdn;
658                 } else {
659                         $new{$fd} = $idle_at;
660                 }
661         }
662         $EXPMAP = \%new;
663         $exp_timer = scalar(keys %new) ? later(\&expire_old) : undef;
664 }
665
666 sub update_idle_time {
667         my ($self) = @_;
668         my $sock = $self->{sock} or return;
669         $EXPMAP->{fileno($sock)} = now();
670         $exp_timer //= later(\&expire_old);
671 }
672
673 sub not_idle_long {
674         my ($self, $now) = @_;
675         my $sock = $self->{sock} or return;
676         my $idle_at = $EXPMAP->{fileno($sock)} or return;
677         ($idle_at + $EXPTIME) > $now;
678 }
679
680 1;
681
682 =head1 AUTHORS (Danga::Socket)
683
684 Brad Fitzpatrick <brad@danga.com> - author
685
686 Michael Granger <ged@danga.com> - docs, testing
687
688 Mark Smith <junior@danga.com> - contributor, heavy user, testing
689
690 Matt Sergeant <matt@sergeant.org> - kqueue support, docs, timers, other bits