unix: clear UV_STREAM_SHUTTING after shutdown()

Fix a state machine buglet where the UV_STREAM_SHUTTING flag didn't get
cleared.
This commit is contained in:
Ben Noordhuis 2013-06-08 03:14:32 +02:00
parent 3ab354367b
commit 536c5f8661

View File

@ -630,6 +630,7 @@ int uv_listen(uv_stream_t* stream, int backlog, uv_connection_cb cb) {
static void uv__drain(uv_stream_t* stream) {
uv_shutdown_t* req;
int status;
assert(ngx_queue_empty(&stream->write_queue));
uv__io_stop(stream->loop, &stream->io_watcher, UV__POLLOUT);
@ -642,21 +643,17 @@ static void uv__drain(uv_stream_t* stream) {
req = stream->shutdown_req;
stream->shutdown_req = NULL;
stream->flags &= ~UV_STREAM_SHUTTING;
uv__req_unregister(stream->loop, req);
if (shutdown(uv__stream_fd(stream), SHUT_WR)) {
/* Error. Report it. User should call uv_close(). */
status = shutdown(uv__stream_fd(stream), SHUT_WR);
if (status)
uv__set_sys_error(stream->loop, errno);
if (req->cb) {
req->cb(req, -1);
}
} else {
uv__set_sys_error(stream->loop, 0);
((uv_handle_t*) stream)->flags |= UV_STREAM_SHUT;
if (req->cb) {
req->cb(req, 0);
}
}
else
stream->flags |= UV_STREAM_SHUT;
if (req->cb != NULL)
req->cb(req, status);
}
}