Skip to content

Commit 01544d8

Browse files
committed
Revert "stream: squelch ECONNRESET error if already closed"
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 <[email protected]>
1 parent 9daef1c commit 01544d8

12 files changed

+12
-161
lines changed

Makefile.am

-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ test_run_tests_SOURCES = test/blackhole-server.c \
224224
test/test-tcp-open.c \
225225
test/test-tcp-read-stop.c \
226226
test/test-tcp-shutdown-after-write.c \
227-
test/test-tcp-squelch-connreset.c \
228227
test/test-tcp-unexpected-read.c \
229228
test/test-tcp-oob.c \
230229
test/test-tcp-write-to-half-open-connection.c \

src/unix/internal.h

+4-10
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,10 @@
8989
#endif
9090

9191
#if defined(__linux__)
92-
# define UV__POLLIN UV__EPOLLIN
93-
# define UV__POLLOUT UV__EPOLLOUT
94-
# define UV__POLLERR UV__EPOLLERR
95-
# define UV__POLLHUP UV__EPOLLHUP
96-
# define UV__POLLRDHUP UV__EPOLLRDHUP
92+
# define UV__POLLIN UV__EPOLLIN
93+
# define UV__POLLOUT UV__EPOLLOUT
94+
# define UV__POLLERR UV__EPOLLERR
95+
# define UV__POLLHUP UV__EPOLLHUP
9796
#endif
9897

9998
#if defined(__sun) || defined(_AIX)
@@ -119,10 +118,6 @@
119118
# define UV__POLLHUP 8
120119
#endif
121120

122-
#ifndef UV__POLLRDHUP
123-
# define UV__POLLRDHUP 0x200
124-
#endif
125-
126121
#if !defined(O_CLOEXEC) && defined(__FreeBSD__)
127122
/*
128123
* It may be that we are just missing `__POSIX_VISIBLE >= 200809`.
@@ -148,7 +143,6 @@ enum {
148143
UV_TCP_NODELAY = 0x400, /* Disable Nagle. */
149144
UV_TCP_KEEPALIVE = 0x800, /* Turn on keep-alive. */
150145
UV_TCP_SINGLE_ACCEPT = 0x1000, /* Only accept() when idle. */
151-
UV_STREAM_DISCONNECT = 0x2000, /* Remote end is forcibly closed */
152146
UV_HANDLE_IPV6 = 0x10000, /* Handle is bound to a IPv6 socket. */
153147
UV_UDP_PROCESSING = 0x20000 /* Handle is running the send callback queue. */
154148
};

src/unix/kqueue.c

-3
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,6 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
241241
if (ev->flags & EV_ERROR)
242242
revents |= UV__POLLERR;
243243

244-
if ((w->pevents & UV__POLLIN) && (ev->flags & EV_EOF))
245-
revents |= UV__POLLRDHUP;
246-
247244
if (revents == 0)
248245
continue;
249246

src/unix/linux-core.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,6 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
184184
assert(w->fd < (int) loop->nwatchers);
185185

186186
e.events = w->pevents;
187-
if (w->pevents & UV__POLLIN)
188-
e.events |= UV__POLLRDHUP;
189187
e.data = w->fd;
190188

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

328326
/* Work around an epoll quirk where it sometimes reports just the
329327
* EPOLLERR or EPOLLHUP event. In order to force the event loop to

src/unix/linux-syscalls.h

-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@
7676
#define UV__EPOLLOUT 4
7777
#define UV__EPOLLERR 8
7878
#define UV__EPOLLHUP 16
79-
#define UV__EPOLLRDHUP 0x2000
8079
#define UV__EPOLLONESHOT 0x40000000
8180
#define UV__EPOLLET 0x80000000
8281

src/unix/poll.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static void uv__poll_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
4141
}
4242

4343
pevents = 0;
44-
if (events & (UV__POLLIN | UV__POLLRDHUP))
44+
if (events & UV__POLLIN)
4545
pevents |= UV_READABLE;
4646
if (events & UV__POLLOUT)
4747
pevents |= UV_WRITABLE;

src/unix/stream.c

+1-6
Original file line numberDiff line numberDiff line change
@@ -1129,8 +1129,6 @@ static void uv__read(uv_stream_t* stream) {
11291129
uv__stream_osx_interrupt_select(stream);
11301130
}
11311131
stream->read_cb(stream, 0, &buf);
1132-
} else if (errno == ECONNRESET && (stream->flags & UV_STREAM_DISCONNECT)) {
1133-
uv__stream_eof(stream, &buf);
11341132
} else {
11351133
/* Error. User should call uv_close(). */
11361134
stream->read_cb(stream, -errno, &buf);
@@ -1219,11 +1217,8 @@ static void uv__stream_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
12191217
assert(uv__stream_fd(stream) >= 0);
12201218

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

12281223
if (uv__stream_fd(stream) == -1)
12291224
return; /* read_cb closed stream. */

test/test-list.h

-6
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,6 @@ TEST_DECLARE (tcp_bind_invalid_flags)
7979
TEST_DECLARE (tcp_listen_without_bind)
8080
TEST_DECLARE (tcp_connect_error_fault)
8181
TEST_DECLARE (tcp_connect_timeout)
82-
#ifndef _WIN32
83-
TEST_DECLARE (tcp_squelch_connreset)
84-
#endif
8582
TEST_DECLARE (tcp_close_while_connecting)
8683
TEST_DECLARE (tcp_close)
8784
TEST_DECLARE (tcp_create_early)
@@ -427,9 +424,6 @@ TASK_LIST_START
427424
TEST_ENTRY (tcp_listen_without_bind)
428425
TEST_ENTRY (tcp_connect_error_fault)
429426
TEST_ENTRY (tcp_connect_timeout)
430-
#ifndef _WIN32
431-
TEST_ENTRY (tcp_squelch_connreset)
432-
#endif
433427
TEST_ENTRY (tcp_close_while_connecting)
434428
TEST_ENTRY (tcp_close)
435429
TEST_ENTRY (tcp_create_early)

test/test-poll.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -204,15 +204,14 @@ static void connection_poll_cb(uv_poll_t* handle, int status, int events) {
204204
/* Read a couple of bytes. */
205205
static char buffer[74];
206206
r = recv(context->sock, buffer, sizeof buffer, 0);
207+
ASSERT(r >= 0);
207208

208209
if (r > 0) {
209210
context->read += r;
210-
} else if (r == 0) {
211+
} else {
211212
/* Got FIN. */
212213
context->got_fin = 1;
213214
new_events &= ~UV_READABLE;
214-
} else {
215-
ASSERT(got_eagain());
216215
}
217216

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

227227
while (r > 0) {
228228
context->read += r;

test/test-tcp-open.c

+2-7
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ static uv_connect_t connect_req;
3838
static uv_shutdown_t shutdown_req;
3939
static uv_write_t write_req;
4040

41-
static int read_bytes = 0;
4241

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

114113
if (nread >= 0) {
115-
read_bytes += nread;
116-
if (nread > 0) {
117-
ASSERT(nread == 4);
118-
ASSERT(memcmp("PING", buf->base, nread) == 0);
119-
}
114+
ASSERT(nread == 4);
115+
ASSERT(memcmp("PING", buf->base, nread) == 0);
120116
}
121117
else {
122118
ASSERT(nread == UV_EOF);
123-
ASSERT(read_bytes == 4);
124119
printf("GOT EOF\n");
125120
uv_close((uv_handle_t*)tcp, close_cb);
126121
}

test/test-tcp-squelch-connreset.c

-119
This file was deleted.

uv.gyp

-1
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,6 @@
364364
'test/test-tcp-connect-timeout.c',
365365
'test/test-tcp-connect6-error.c',
366366
'test/test-tcp-open.c',
367-
'test/test-tcp-squelch-connreset.c',
368367
'test/test-tcp-write-to-half-open-connection.c',
369368
'test/test-tcp-write-after-connect.c',
370369
'test/test-tcp-writealot.c',

0 commit comments

Comments
 (0)