Permalink
Browse files

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.
  • Loading branch information...
1 parent e10a87a commit e82d46452e3db141d3875286cf90be0de6d724e0 @bnoordhuis bnoordhuis committed May 17, 2012
Showing with 7 additions and 0 deletions.
  1. +7 −0 src/unix/stream.c
View
@@ -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);

0 comments on commit e82d464

Please sign in to comment.