Roger Pack wrote:
> I used to catch Errno::EINVAL when using lots of open file descriptors
> and [ruby] threads on win32 [and probably still would except I went
> single threaded and switched to Linux to side step the problem].
> Never figured it out.  Sometimes sockets would 'read' one another's
> data, too, and sometimes a close on one socket would close another
> different socket.  I assume yours works splendidly with the normal
> memory allocator?

This sounds like an obvious case of double closing file descriptors. 
File descriptor numbers on many operating systems are "recycled", e.g.:

int fd1, fd2, fd3;
fd1 = open(...);    // fd1 == 3
fd2 = open(...);    // fd2 == 4;
close(fd1);
fd3 = open(...);    // fd3 == 3, 3 has been "recycled"

If you call close(fd1) at the end (double closing) then it would wrongly 
close fd3.

Issues like these are pretty serious. Maybe there's a double closing bug 
in Ruby somewhere.