EVALUATION
The problem seems to be the Mac OS X poll() bug. What is happening is that the first http transaction
suceeeds and the second one is attempted by the browser on the same tcp connection.
It hangs because it is blocked in poll(), which doesn't wakeup on the presence of new data.
When the keep-alive timer expires on the server, the server closes the connection because it doesn't
see any data. The client then repeats the request on a second connection, which succeeds immediately.
if you wait for the (kept-alive) TCP connection to be closed, before making the second request then
it returns immediately (because it is happening on a new connection).
The problem seems to be fixed by replacing the poll() code with an emulation based on select().
However, this seems to create other problems when connections timeout. select() returning EBADF.
|