Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
windows: make sure sockets and handles are reset on close
Browse files Browse the repository at this point in the history
Set the socket to INVALID_SOCKET foir TCP and UDP handles and
the handle to INVALID_HANDLE_VALUE on TTY handles after closing them.
  • Loading branch information
saghul committed Aug 27, 2014
1 parent 4ca9a36 commit fabafd6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/win/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ void uv_tcp_endgame(uv_loop_t* loop, uv_tcp_t* handle) {

if (!(handle->flags & UV_HANDLE_TCP_SOCKET_CLOSED)) {
closesocket(handle->socket);
handle->socket = INVALID_SOCKET;
handle->flags |= UV_HANDLE_TCP_SOCKET_CLOSED;
}

Expand Down Expand Up @@ -1368,6 +1369,7 @@ void uv_tcp_close(uv_loop_t* loop, uv_tcp_t* tcp) {

if (close_socket) {
closesocket(tcp->socket);
tcp->socket = INVALID_SOCKET;
tcp->flags |= UV_HANDLE_TCP_SOCKET_CLOSED;
}

Expand Down
1 change: 1 addition & 0 deletions src/win/tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -1903,6 +1903,7 @@ void uv_tty_close(uv_tty_t* handle) {
if (handle->flags & UV_HANDLE_READING)
uv_tty_read_stop(handle);

handle->handle = INVALID_HANDLE_VALUE;
handle->flags &= ~(UV_HANDLE_READABLE | UV_HANDLE_WRITABLE);
uv__handle_closing(handle);

Expand Down
1 change: 1 addition & 0 deletions src/win/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ int uv_udp_init(uv_loop_t* loop, uv_udp_t* handle) {
void uv_udp_close(uv_loop_t* loop, uv_udp_t* handle) {
uv_udp_recv_stop(handle);
closesocket(handle->socket);
handle->socket = INVALID_SOCKET;

uv__handle_closing(handle);

Expand Down

0 comments on commit fabafd6

Please sign in to comment.