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