unix: fix close-before-connect bug

Closing the TCP socket before the SYN/ACK handshake completed hung the event
loop, the connect req didn't get unregistered.
This commit is contained in:
Ben Noordhuis 2012-05-18 01:16:29 +02:00
parent e10a87adb9
commit e82d46452e

View File

@ -129,6 +129,13 @@ void uv__stream_destroy(uv_stream_t* stream) {
assert(stream->flags & UV_CLOSED);
if (stream->connect_req) {
uv__req_unregister(stream->loop, stream->connect_req);
uv__set_artificial_error(stream->loop, UV_EINTR);
stream->connect_req->cb(stream->connect_req, -1);
stream->connect_req = NULL;
}
while (!ngx_queue_empty(&stream->write_queue)) {
q = ngx_queue_head(&stream->write_queue);
ngx_queue_remove(q);