Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
libuv: Delay closing the socket when read is pending
On Windows, do not skip delaying the closesocket
when the socket is not shared with another process -
I don't see any reason which will allow this optimization

Refs: #35946
Refs: libuv/libuv#3034
  • Loading branch information
mmomtchev committed Nov 4, 2020
commit 87baa7551854163a343d96dbfd05bb32122697f6
6 changes: 1 addition & 5 deletions deps/uv/src/win/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1429,11 +1429,7 @@ void uv_tcp_close(uv_loop_t* loop, uv_tcp_t* tcp) {
if (tcp->flags & UV_HANDLE_READ_PENDING) {
/* In order for winsock to do a graceful close there must not be any any
* pending reads, or the socket must be shut down for writing */
if (!(tcp->flags & UV_HANDLE_SHARED_TCP_SOCKET)) {
/* Just do shutdown on non-shared sockets, which ensures graceful close. */
shutdown(tcp->socket, SD_SEND);

} else if (uv_tcp_try_cancel_io(tcp) == 0) {
if (uv_tcp_try_cancel_io(tcp) == 0) {
/* In case of a shared socket, we try to cancel all outstanding I/O,. If
* that works, don't close the socket yet - wait for the read req to
* return and close the socket in uv_tcp_endgame. */
Expand Down
5 changes: 1 addition & 4 deletions lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -815,10 +815,7 @@ function resOnFinish(req, res, socket, state, server) {

if (res._last) {
if (typeof socket.destroySoon === 'function') {
if (socket.readableEnded)
socket.destroySoon();
else
socket.on('end', socket.destroySoon);
socket.destroySoon();
} else {
socket.end();
}
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-https-truncate.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function httpsTest() {

server.listen(0, function() {
const opts = { port: this.address().port, rejectUnauthorized: false };
https.get(opts).on('response', function (res) {
https.get(opts).on('response', function(res) {
test(res);
});
});
Expand Down