Permalink
Browse files

test: don't assert on UV_EPIPE in echo-server.c

UV_EPIPE is not an error per se, it simply indicates that the other end of the
connection - i.e. the test case - has gone away.

Pro-actively ignore UV_ECANCELED errors. They're not actually emitted right now
because there's only ever one pending write but let's be forward compatible.
  • Loading branch information...
1 parent 225c6f1 commit b8aa5b9bf25648395050d9ec20d488a24306a3d8 @bnoordhuis bnoordhuis committed Nov 1, 2012
Showing with 14 additions and 8 deletions.
  1. +14 −8 test/echo-server.c
View
22 test/echo-server.c
@@ -47,18 +47,24 @@ static void on_connection(uv_stream_t*, int status);
static void after_write(uv_write_t* req, int status) {
write_req_t* wr;
-
- if (status) {
- uv_err_t err = uv_last_error(loop);
- fprintf(stderr, "uv_write error: %s\n", uv_strerror(err));
- ASSERT(0);
- }
-
- wr = (write_req_t*) req;
+ uv_err_t err;
/* Free the read/write buffer and the request */
+ wr = (write_req_t*) req;
free(wr->buf.base);
free(wr);
+
+ if (status == 0)
+ return;
+
+ err = uv_last_error(loop);
+ fprintf(stderr, "uv_write error: %s\n", uv_strerror(err));
+
+ if (err.code == UV_ECANCELED)
+ return;
+
+ ASSERT(err.code == UV_EPIPE);
+ uv_close((uv_handle_t*)req->handle, on_close);
}

0 comments on commit b8aa5b9

Please sign in to comment.