summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-04-10 08:02:38 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-04-10 08:02:38 +0000
commit20e961458e9f34504dc07712ad6b0e8aa1d165f8 (patch)
tree355ebc80626f5208417953bba9299b0b571166e5 /win32
parent00f60d074804e2d3a74c6108e40cd5910865f7fc (diff)
* win32/win32.c (rb_w32_fclose, rb_w32_close): need to save errno
before calling original fclose()/close(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32')
-rw-r--r--win32/win32.c4
1 files changed, 4 insertions, 0 deletions
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;