Skip to content

Instantly share code, notes, and snippets.

@saghul
Created September 10, 2014 20:36
Show Gist options
  • Save saghul/03641437563268ab04f2 to your computer and use it in GitHub Desktop.
Save saghul/03641437563268ab04f2 to your computer and use it in GitHub Desktop.
diff --git a/test/echo-server.c b/test/echo-server.c
index 8a8366f..29736ea 100644
--- a/test/echo-server.c
+++ b/test/echo-server.c
@@ -63,18 +63,26 @@ static void after_write(uv_write_t* req, int status) {
}
+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 *sreq;
if (nread < 0) {
/* Error or EOF */
ASSERT(nread == UV_EOF);
free(buf->base);
- uv_close((uv_handle_t*) handle, on_close);
+ sreq = malloc(sizeof *sreq);
+ ASSERT(0 == uv_shutdown(sreq, handle, after_shutdown));
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment