diff options
Diffstat (limited to 'win32/win32.c')
-rw-r--r-- | win32/win32.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/win32/win32.c b/win32/win32.c index f82a2f4494..cd344eac94 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -3634,6 +3634,7 @@ rb_w32_fclose(FILE *fp) { int fd = fileno(fp); SOCKET sock = TO_SOCKET(fd); + int save_errno = errno; if (fflush(fp)) return -1; if (!is_socket(sock)) { @@ -3642,6 +3643,7 @@ rb_w32_fclose(FILE *fp) } _set_osfhnd(fd, (SOCKET)INVALID_HANDLE_VALUE); fclose(fp); + errno = save_errno; if (closesocket(sock) == SOCKET_ERROR) { errno = map_errno(WSAGetLastError()); return -1; @@ -3653,6 +3655,7 @@ int rb_w32_close(int fd) { SOCKET sock = TO_SOCKET(fd); + int save_errno = errno; if (!is_socket(sock)) { UnlockFile((HANDLE)sock, 0, 0, LK_LEN, LK_LEN); @@ -3660,6 +3663,7 @@ rb_w32_close(int fd) } _set_osfhnd(fd, (SOCKET)INVALID_HANDLE_VALUE); _close(fd); + errno = save_errno; if (closesocket(sock) == SOCKET_ERROR) { errno = map_errno(WSAGetLastError()); return -1; |