Skip to content

Commit 7d4ea94

Browse files
committed
Always close the connection on error.
1 parent a4d5fae commit 7d4ea94

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/httpserver.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,13 @@ void on_read(uv_stream_t* tcp, ssize_t nread, uv_buf_t buf) {
114114
close_connection(client);
115115
}
116116
} else if (nread < 0) {
117+
// Always close the connection on error.
118+
// https://groups.google.com/forum/?fromgroups=#!topic/libuv/IG7tTbf6Zmg
117119
uv_err_t err = uv_last_error(uv_loop);
118120
if (err.code != UV_EOF) {
119121
UVERR(err, "read");
120-
close_connection(client);
121122
}
123+
close_connection(client);
122124
}
123125

124126
free(buf.base);

0 commit comments

Comments
 (0)