diff --git a/ChangeLog b/ChangeLog index 4fe1e3692c..9c80de2264 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Apr 10 17:02:17 2007 NAKAMURA Usaku + + * win32/win32.c (rb_w32_fclose, rb_w32_close): need to save errno + before calling original fclose()/close(). + Tue Apr 10 16:14:22 2007 NAKAMURA Usaku * thread_win32.ci (w32_wait_events): check whether interrupt_event is diff --git a/win32/win32.c b/win32/win32.c index 3c8be568d9..8d1f3e483f 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -3944,6 +3944,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)) { @@ -3952,6 +3953,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; @@ -3963,6 +3965,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); @@ -3970,6 +3973,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;