ext/libuv/src/unix/stream.c in libuv-1.1.3 vs ext/libuv/src/unix/stream.c in libuv-1.2.0
- old
+ new
@@ -547,11 +547,10 @@
assert(server->loop == client->loop);
if (server->accepted_fd == -1)
return -EAGAIN;
- err = 0;
switch (client->type) {
case UV_NAMED_PIPE:
case UV_TCP:
err = uv__stream_open(client,
server->accepted_fd,
@@ -949,10 +948,11 @@
uv__io_stop(stream->loop, &stream->io_watcher, UV__POLLIN);
if (!uv__io_active(&stream->io_watcher, UV__POLLOUT))
uv__handle_stop(stream);
uv__stream_osx_interrupt_select(stream);
stream->read_cb(stream, UV_EOF, buf);
+ stream->flags &= ~UV_STREAM_READING;
}
static int uv__stream_queue_fd(uv_stream_t* stream, int fd) {
uv__stream_queued_fds_t* queued_fds;
@@ -1115,12 +1115,17 @@
}
stream->read_cb(stream, 0, &buf);
} else {
/* Error. User should call uv_close(). */
stream->read_cb(stream, -errno, &buf);
- assert(!uv__io_active(&stream->io_watcher, UV__POLLIN) &&
- "stream->read_cb(status=-1) did not call uv_close()");
+ if (stream->flags & UV_STREAM_READING) {
+ stream->flags &= ~UV_STREAM_READING;
+ uv__io_stop(stream->loop, &stream->io_watcher, UV__POLLIN);
+ if (!uv__io_active(&stream->io_watcher, UV__POLLOUT))
+ uv__handle_stop(stream);
+ uv__stream_osx_interrupt_select(stream);
+ }
}
return;
} else if (nread == 0) {
uv__stream_eof(stream, &buf);
return;
@@ -1317,11 +1322,11 @@
}
/* It's legal for write_queue_size > 0 even when the write_queue is empty;
* it means there are error-state requests in the write_completed_queue that
* will touch up write_queue_size later, see also uv__write_req_finish().
- * We chould check that write_queue is empty instead but that implies making
+ * We could check that write_queue is empty instead but that implies making
* a write() syscall when we know that the handle is in error mode.
*/
empty_queue = (stream->write_queue_size == 0);
/* Initialize the req */
@@ -1469,18 +1474,11 @@
return 0;
}
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) ||
- !QUEUE_EMPTY(&stream->write_completed_queue) ||
- !QUEUE_EMPTY(&stream->write_queue) ||
- stream->shutdown_req != NULL ||
- stream->connect_req != NULL);
+ if (!(stream->flags & UV_STREAM_READING))
+ return 0;
stream->flags &= ~UV_STREAM_READING;
uv__io_stop(stream->loop, &stream->io_watcher, UV__POLLIN);
if (!uv__io_active(&stream->io_watcher, UV__POLLOUT))
uv__handle_stop(stream);