mirror of
https://github.com/libuv/libuv
synced 2025-03-28 21:13:16 +00:00
test: don't close connection on write error
The echo server shouldn't close the connection when there's an error on write. Instead simply echo the error message and allow the other side to close the connection. Also do a partial revert of 4d905fb where after_shutdown was removed. Fixes: 4d905fb "test: close stream immediately on error" Signed-off-by: Trevor Norris <trev.norris@gmail.com> Signed-off-by: Saúl Ibarra Corretgé <saghul@gmail.com>
This commit is contained in:
parent
54ce3f6c8e
commit
3d38eae377
@ -51,20 +51,21 @@ static void after_write(uv_write_t* req, int status) {
|
||||
/* Free the read/write buffer and the request */
|
||||
wr = (write_req_t*) req;
|
||||
free(wr->buf.base);
|
||||
free(wr);
|
||||
|
||||
if (status == 0) {
|
||||
free(wr);
|
||||
if (status == 0)
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(stderr,
|
||||
"uv_write error: %s - %s\n",
|
||||
uv_err_name(status),
|
||||
uv_strerror(status));
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@ -73,16 +74,15 @@ static void after_read(uv_stream_t* handle,
|
||||
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);
|
||||
|
||||
if (buf->base) {
|
||||
free(buf->base);
|
||||
}
|
||||
|
||||
uv_close((uv_handle_t*) handle, on_close);
|
||||
free(buf->base);
|
||||
sreq = malloc(sizeof* sreq);
|
||||
ASSERT(0 == uv_shutdown(sreq, handle, after_shutdown));
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user