From b38c9c1004993ca4f642629f5af1b7b09bbc6887 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sat, 25 May 2013 02:36:45 +0200 Subject: [PATCH] unix: remove erroneous asserts As of commit c53fe81, it's legal for write_queue_size > 0 when the write_queue itself is empty. Sounds illogical but it means there are error-state write requests in the write_completed_queue that will touch up the write_queue_size on the next tick of the event loop. Remove a few stray asserts that still checked for the old situation. --- src/unix/stream.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/unix/stream.c b/src/unix/stream.c index fb1be0050..892838ccc 100644 --- a/src/unix/stream.c +++ b/src/unix/stream.c @@ -632,8 +632,6 @@ static void uv__drain(uv_stream_t* stream) { uv_shutdown_t* req; assert(ngx_queue_empty(&stream->write_queue)); - assert(stream->write_queue_size == 0); - uv__io_stop(stream->loop, &stream->io_watcher, UV__POLLOUT); /* Shutdown? */ @@ -727,10 +725,8 @@ start: assert(uv__stream_fd(stream) >= 0); - if (ngx_queue_empty(&stream->write_queue)) { - assert(stream->write_queue_size == 0); + if (ngx_queue_empty(&stream->write_queue)) return; - } q = ngx_queue_head(&stream->write_queue); req = ngx_queue_data(q, uv_write_t, queue); @@ -1205,6 +1201,12 @@ int uv_write2(uv_write_t* req, return uv__set_artificial_error(stream->loop, UV_EBADF); } + /* 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 + * a write() syscall when we know that the handle is in error mode. + */ empty_queue = (stream->write_queue_size == 0); /* Initialize the req */