Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

windows: turn WSAECONNABORTED from WSARecv to UV_ECONNRESET

  • Loading branch information...
Igor Zinkovsky
Igor Zinkovsky committed Nov 9, 2011
1 parent 4794c12 commit f17d4837a8c2e406daa36bce8bd787021a09cef4
Showing with 10 additions and 12 deletions.
  1. +8 −6 src/win/tcp.c
  2. +2 −6 test/test-tcp-write-to-half-open-connection.c
@@ -830,9 +830,10 @@ void uv_process_tcp_read_req(uv_loop_t* loop, uv_tcp_t* handle,
err = GET_REQ_SOCK_ERROR(req);

if (err == WSAECONNABORTED) {
/* Treat WSAECONNABORTED as connection closed. */
handle->flags |= UV_HANDLE_EOF;
uv__set_error(loop, UV_EOF, ERROR_SUCCESS);
/*
* Turn WSAECONNABORTED into UV_ECONNRESET to be consistent with Unix.
*/
uv__set_error(loop, UV_ECONNRESET, err);
} else {
uv__set_sys_error(loop, err);
}
@@ -898,9 +899,10 @@ void uv_process_tcp_read_req(uv_loop_t* loop, uv_tcp_t* handle,
handle->read_cb((uv_stream_t*)handle, 0, buf);
} else {
if (err == WSAECONNABORTED) {
/* Treat WSAECONNABORTED as connection closed. */
handle->flags |= UV_HANDLE_EOF;
uv__set_error(loop, UV_EOF, ERROR_SUCCESS);
/*
* Turn WSAECONNABORTED into UV_ECONNRESET to be consistent with Unix.
*/
uv__set_error(loop, UV_ECONNRESET, err);
} else {
/* Ouch! serious error. */
uv__set_sys_error(loop, err);
@@ -40,8 +40,6 @@ static uv_write_t write_req;

static int write_cb_called;
static int read_cb_called;
static int read_eof_cb_called;


static void connection_cb(uv_stream_t* server, int status) {
int r;
@@ -76,12 +74,11 @@ static uv_buf_t alloc_cb(uv_handle_t* handle, size_t suggested_size) {
static void read_cb(uv_stream_t* stream, ssize_t nread, uv_buf_t buf) {
if (nread == -1) {
fprintf(stderr, "read_cb error: %s\n", uv_err_name(uv_last_error(stream->loop)));
ASSERT(uv_last_error(stream->loop).code == UV_EOF);
ASSERT(uv_last_error(stream->loop).code == UV_ECONNRESET ||
uv_last_error(stream->loop).code == UV_EOF);

uv_close((uv_handle_t*)&tcp_server, NULL);
uv_close((uv_handle_t*)&tcp_peer, NULL);

read_eof_cb_called++;
}

read_cb_called++;
@@ -133,7 +130,6 @@ TEST_IMPL(tcp_write_to_half_open_connection) {

ASSERT(write_cb_called > 0);
ASSERT(read_cb_called > 0);
ASSERT(read_eof_cb_called > 0);

return 0;
}

0 comments on commit f17d483

Please sign in to comment.
You can’t perform that action at this time.