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