Skip to content

Commit

Permalink
Revert "stream: squelch ECONNRESET error if already closed"
Browse files Browse the repository at this point in the history
This reverts commit 05a003a.

This commit triggerd "test-tls-hello-parser-failure" failure in io.js.
See the reference below for a more thorough explanation.

Refs: nodejs/node#2310
PR-URL: libuv#475
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
  • Loading branch information
saghul committed Aug 7, 2015
1 parent 9daef1c commit 01544d8
Show file tree
Hide file tree
Showing 12 changed files with 12 additions and 161 deletions.
1 change: 0 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ test_run_tests_SOURCES = test/blackhole-server.c \
test/test-tcp-open.c \
test/test-tcp-read-stop.c \
test/test-tcp-shutdown-after-write.c \
test/test-tcp-squelch-connreset.c \
test/test-tcp-unexpected-read.c \
test/test-tcp-oob.c \
test/test-tcp-write-to-half-open-connection.c \
Expand Down
14 changes: 4 additions & 10 deletions src/unix/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,10 @@
#endif

#if defined(__linux__)
# define UV__POLLIN UV__EPOLLIN
# define UV__POLLOUT UV__EPOLLOUT
# define UV__POLLERR UV__EPOLLERR
# define UV__POLLHUP UV__EPOLLHUP
# define UV__POLLRDHUP UV__EPOLLRDHUP
# define UV__POLLIN UV__EPOLLIN
# define UV__POLLOUT UV__EPOLLOUT
# define UV__POLLERR UV__EPOLLERR
# define UV__POLLHUP UV__EPOLLHUP
#endif

#if defined(__sun) || defined(_AIX)
Expand All @@ -119,10 +118,6 @@
# define UV__POLLHUP 8
#endif

#ifndef UV__POLLRDHUP
# define UV__POLLRDHUP 0x200
#endif

#if !defined(O_CLOEXEC) && defined(__FreeBSD__)
/*
* It may be that we are just missing `__POSIX_VISIBLE >= 200809`.
Expand All @@ -148,7 +143,6 @@ enum {
UV_TCP_NODELAY = 0x400, /* Disable Nagle. */
UV_TCP_KEEPALIVE = 0x800, /* Turn on keep-alive. */
UV_TCP_SINGLE_ACCEPT = 0x1000, /* Only accept() when idle. */
UV_STREAM_DISCONNECT = 0x2000, /* Remote end is forcibly closed */
UV_HANDLE_IPV6 = 0x10000, /* Handle is bound to a IPv6 socket. */
UV_UDP_PROCESSING = 0x20000 /* Handle is running the send callback queue. */
};
Expand Down
3 changes: 0 additions & 3 deletions src/unix/kqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,6 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
if (ev->flags & EV_ERROR)
revents |= UV__POLLERR;

if ((w->pevents & UV__POLLIN) && (ev->flags & EV_EOF))
revents |= UV__POLLRDHUP;

if (revents == 0)
continue;

Expand Down
4 changes: 1 addition & 3 deletions src/unix/linux-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,6 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
assert(w->fd < (int) loop->nwatchers);

e.events = w->pevents;
if (w->pevents & UV__POLLIN)
e.events |= UV__POLLRDHUP;
e.data = w->fd;

if (w->events == 0)
Expand Down Expand Up @@ -323,7 +321,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
* the current watcher. Also, filters out events that users has not
* requested us to watch.
*/
pe->events &= w->pevents | UV__POLLERR | UV__POLLHUP | UV__POLLRDHUP;
pe->events &= w->pevents | UV__POLLERR | UV__POLLHUP;

/* Work around an epoll quirk where it sometimes reports just the
* EPOLLERR or EPOLLHUP event. In order to force the event loop to
Expand Down
1 change: 0 additions & 1 deletion src/unix/linux-syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
#define UV__EPOLLOUT 4
#define UV__EPOLLERR 8
#define UV__EPOLLHUP 16
#define UV__EPOLLRDHUP 0x2000
#define UV__EPOLLONESHOT 0x40000000
#define UV__EPOLLET 0x80000000

Expand Down
2 changes: 1 addition & 1 deletion src/unix/poll.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static void uv__poll_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
}

pevents = 0;
if (events & (UV__POLLIN | UV__POLLRDHUP))
if (events & UV__POLLIN)
pevents |= UV_READABLE;
if (events & UV__POLLOUT)
pevents |= UV_WRITABLE;
Expand Down
7 changes: 1 addition & 6 deletions src/unix/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -1129,8 +1129,6 @@ static void uv__read(uv_stream_t* stream) {
uv__stream_osx_interrupt_select(stream);
}
stream->read_cb(stream, 0, &buf);
} else if (errno == ECONNRESET && (stream->flags & UV_STREAM_DISCONNECT)) {
uv__stream_eof(stream, &buf);
} else {
/* Error. User should call uv_close(). */
stream->read_cb(stream, -errno, &buf);
Expand Down Expand Up @@ -1219,11 +1217,8 @@ static void uv__stream_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
assert(uv__stream_fd(stream) >= 0);

/* Ignore POLLHUP here. Even it it's set, there may still be data to read. */
if (events & (UV__POLLIN | UV__POLLERR | UV__POLLHUP | UV__POLLRDHUP)) {
if (events & UV__POLLRDHUP)
stream->flags |= UV_STREAM_DISCONNECT;
if (events & (UV__POLLIN | UV__POLLERR | UV__POLLHUP))
uv__read(stream);
}

if (uv__stream_fd(stream) == -1)
return; /* read_cb closed stream. */
Expand Down
6 changes: 0 additions & 6 deletions test/test-list.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ TEST_DECLARE (tcp_bind_invalid_flags)
TEST_DECLARE (tcp_listen_without_bind)
TEST_DECLARE (tcp_connect_error_fault)
TEST_DECLARE (tcp_connect_timeout)
#ifndef _WIN32
TEST_DECLARE (tcp_squelch_connreset)
#endif
TEST_DECLARE (tcp_close_while_connecting)
TEST_DECLARE (tcp_close)
TEST_DECLARE (tcp_create_early)
Expand Down Expand Up @@ -427,9 +424,6 @@ TASK_LIST_START
TEST_ENTRY (tcp_listen_without_bind)
TEST_ENTRY (tcp_connect_error_fault)
TEST_ENTRY (tcp_connect_timeout)
#ifndef _WIN32
TEST_ENTRY (tcp_squelch_connreset)
#endif
TEST_ENTRY (tcp_close_while_connecting)
TEST_ENTRY (tcp_close)
TEST_ENTRY (tcp_create_early)
Expand Down
6 changes: 3 additions & 3 deletions test/test-poll.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,14 @@ static void connection_poll_cb(uv_poll_t* handle, int status, int events) {
/* Read a couple of bytes. */
static char buffer[74];
r = recv(context->sock, buffer, sizeof buffer, 0);
ASSERT(r >= 0);

if (r > 0) {
context->read += r;
} else if (r == 0) {
} else {
/* Got FIN. */
context->got_fin = 1;
new_events &= ~UV_READABLE;
} else {
ASSERT(got_eagain());
}

break;
Expand All @@ -223,6 +222,7 @@ static void connection_poll_cb(uv_poll_t* handle, int status, int events) {
/* Read until EAGAIN. */
static char buffer[931];
r = recv(context->sock, buffer, sizeof buffer, 0);
ASSERT(r >= 0);

while (r > 0) {
context->read += r;
Expand Down
9 changes: 2 additions & 7 deletions test/test-tcp-open.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ static uv_connect_t connect_req;
static uv_shutdown_t shutdown_req;
static uv_write_t write_req;

static int read_bytes = 0;

static void startup(void) {
#ifdef _WIN32
Expand Down Expand Up @@ -112,15 +111,11 @@ static void read_cb(uv_stream_t* tcp, ssize_t nread, const uv_buf_t* buf) {
ASSERT(tcp != NULL);

if (nread >= 0) {
read_bytes += nread;
if (nread > 0) {
ASSERT(nread == 4);
ASSERT(memcmp("PING", buf->base, nread) == 0);
}
ASSERT(nread == 4);
ASSERT(memcmp("PING", buf->base, nread) == 0);
}
else {
ASSERT(nread == UV_EOF);
ASSERT(read_bytes == 4);
printf("GOT EOF\n");
uv_close((uv_handle_t*)tcp, close_cb);
}
Expand Down
119 changes: 0 additions & 119 deletions test/test-tcp-squelch-connreset.c

This file was deleted.

1 change: 0 additions & 1 deletion uv.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@
'test/test-tcp-connect-timeout.c',
'test/test-tcp-connect6-error.c',
'test/test-tcp-open.c',
'test/test-tcp-squelch-connreset.c',
'test/test-tcp-write-to-half-open-connection.c',
'test/test-tcp-write-after-connect.c',
'test/test-tcp-writealot.c',
Expand Down

0 comments on commit 01544d8

Please sign in to comment.