From 066dc6bcc86f8147ef40e15c4ce22e2abe33e661 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 14 Sep 2011 01:42:44 +0200 Subject: [PATCH] unix: fix argument check / write request init order --- src/unix/stream.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/unix/stream.c b/src/unix/stream.c index 8577caf0..24c5557c 100644 --- a/src/unix/stream.c +++ b/src/unix/stream.c @@ -635,6 +635,16 @@ int uv_write(uv_write_t* req, uv_stream_t* stream, uv_buf_t bufs[], int bufcnt, uv_write_cb cb) { int empty_queue; + assert((stream->type == UV_TCP || stream->type == UV_NAMED_PIPE) + && "uv_write (unix) does not yet support other types of streams"); + + if (stream->fd < 0) { + uv_err_new(stream->loop, EBADF); + return -1; + } + + empty_queue = (stream->write_queue_size == 0); + /* Initialize the req */ uv__req_init((uv_req_t*) req); req->cb = cb; @@ -642,16 +652,6 @@ int uv_write(uv_write_t* req, uv_stream_t* stream, uv_buf_t bufs[], int bufcnt, req->type = UV_WRITE; ngx_queue_init(&req->queue); - assert((stream->type == UV_TCP || stream->type == UV_NAMED_PIPE) - && "uv_write (unix) does not yet support other types of streams"); - - empty_queue = (stream->write_queue_size == 0); - - if (stream->fd < 0) { - uv_err_new(stream->loop, EBADF); - return -1; - } - if (bufcnt < UV_REQ_BUFSML_SIZE) { req->bufs = req->bufsml; }