summaryrefslogtreecommitdiff
path: root/deps/uv/src/unix/stream.c
diff options
context:
space:
mode:
Diffstat (limited to 'deps/uv/src/unix/stream.c')
-rw-r--r--deps/uv/src/unix/stream.c36
1 files changed, 12 insertions, 24 deletions
diff --git a/deps/uv/src/unix/stream.c b/deps/uv/src/unix/stream.c
index 52972d9cef..c9df979772 100644
--- a/deps/uv/src/unix/stream.c
+++ b/deps/uv/src/unix/stream.c
@@ -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);
}
}
@@ -1121,7 +1118,7 @@ static void uv__stream_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
return; /* read_cb closed stream. */
}
- if (events & UV__POLLOUT) {
+ if (events & (UV__POLLOUT | UV__POLLERR | UV__POLLHUP)) {
assert(uv__stream_fd(stream) >= 0);
uv__write(stream);
uv__write_callbacks(stream);
@@ -1318,16 +1315,6 @@ int uv_read2_start(uv_stream_t* stream, uv_alloc_cb alloc_cb,
int uv_read_stop(uv_stream_t* stream) {
- /* Sanity check. We're going to stop the handle unless it's primed for
- * writing but that means there should be some kind of write action in
- * progress.
- */
- assert(!uv__io_active(&stream->io_watcher, UV__POLLOUT) ||
- !ngx_queue_empty(&stream->write_completed_queue) ||
- !ngx_queue_empty(&stream->write_queue) ||
- stream->shutdown_req != NULL ||
- stream->connect_req != NULL);
-
stream->flags &= ~UV_STREAM_READING;
uv__io_stop(stream->loop, &stream->io_watcher, UV__POLLIN);
if (!uv__io_active(&stream->io_watcher, UV__POLLOUT))
@@ -1395,8 +1382,9 @@ void uv__stream_close(uv_stream_t* handle) {
}
#endif /* defined(__APPLE__) */
- uv_read_stop(handle);
uv__io_close(handle->loop, &handle->io_watcher);
+ uv_read_stop(handle);
+ uv__handle_stop(handle);
close(handle->io_watcher.fd);
handle->io_watcher.fd = -1;