ext/libuv/test/echo-server.c in libuv-0.12.4 vs ext/libuv/test/echo-server.c in libuv-1.0.0

- old
+ new

@@ -49,48 +49,41 @@ write_req_t* wr; /* Free the read/write buffer and the request */ wr = (write_req_t*) req; free(wr->buf.base); - free(wr); - if (status == 0) + if (status == 0) { + free(wr); return; + } - fprintf(stderr, "uv_write error: %s\n", uv_strerror(status)); + fprintf(stderr, + "uv_write error: %s - %s\n", + uv_err_name(status), + uv_strerror(status)); - if (status == UV_ECANCELED) - return; - - ASSERT(status == UV_EPIPE); - uv_close((uv_handle_t*)req->handle, on_close); + if (!uv_is_closing((uv_handle_t*) req->handle)) + uv_close((uv_handle_t*) req->handle, on_close); + free(wr); } -static void after_shutdown(uv_shutdown_t* req, int status) { - uv_close((uv_handle_t*)req->handle, on_close); - free(req); -} - - static void after_read(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) { int i; write_req_t *wr; - uv_shutdown_t* req; if (nread < 0) { /* Error or EOF */ ASSERT(nread == UV_EOF); if (buf->base) { free(buf->base); } - req = (uv_shutdown_t*) malloc(sizeof *req); - uv_shutdown(req, handle, after_shutdown); - + uv_close((uv_handle_t*) handle, on_close); return; } if (nread == 0) { /* Everything OK, but nothing read. */