dan_b from #lisp suggested that I try to work around the cmucl threading issues by using sockets in non-blocking mode. It was a great suggestion.
I have a new, non-blocking connect-to-inet-socket.
It puts the socket into non-blocking mode, tries to connect, uses system:wait-until-fd-usable (does anyone know what the difference between that and multiprocessing:process-wait-until-fd-usable is?) to nicely block just the current lisp thread until the connect finishes. If the connect worked then the socket is put back into blocking mode and returned.
I use a technique I saw at http://cr.yp.to/docs/connect.html: To figure out whether the async connect succeeded, I call unix:get-peername, and if it returns a negative integer the connect failed. If the connect did fail, in order to figure out the reason for the failure I try to read a single character from the socket with unix:unix-read, which will definitely fail, but more importantly it will set errno according to the reason for the connect failure.
It's been running for a couple days and seems to be working great.
Posted by jjwiseman at January 31, 2002 10:24 AMIt seems that mp:process-wait-... might be slightly more thread-friendly than system:wait-...
Posted by: jjwiseman on February 10, 2002 12:30 AM