[racket] Problems trying to do non-blocking I/O and a reactor loop

From: Greg Hendershott (greghendershott at gmail.com)
Date: Fri Aug 3 19:11:44 EDT 2012

Even the distilled code is maybe a wee bit long for here, so I made a gist:

I wanted to try doing non-blocking I/O and a reactor event loop.

The gist is an excerpt to simplify the problem case. What I left out
is the fun stuff where Racket could make this less painful, such as
using continuations or simply generators to avoid
nested-callback-chain heck. But before the fun stuff, the foundation:

Under a light load everything works fine. But ApacheBench with -c > 2
is making it unhappy, as described in the comments.

Sometimes it will blow through 10,000 reqs at -c 20 with no problem.
And giving at least 2X better reqs/sec than comparable
thread-per-connection example. Yay!

But on most runs it's getting errors with "input port closed".  And
rarely I will get a channel? from sync when it should only be an
eof-object? or integer.  And rarely I even get a Racket seg fault.

So. Probably I'm doing one or more really stupid things?  Any advice
would be welcome -- thank you!

Posted on the users mailing list.