summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-05-23 01:21:33 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-05-23 01:21:33 +0000
commit87c8c5edf43a7f7d33d5fe75f51ef410a03b93b1 (patch)
tree7a209b543d77ef455a3305c1c30e1dd9cb652c38
parent510bbe015dcc1f4f6ecfceedbafed0fdef688961 (diff)
* win32/win32.c (finish_overlapped_socket, overlapped_socket_io):
replace ECONNABORTED to EPIPE in send, sendto and sendmsg to improve BSD socket compatibility. this change removes a failure on the test of net/ftp. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35762 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--win32/win32.c29
2 files changed, 28 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index e104327..5401882 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Wed May 23 10:18:54 2012 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * win32/win32.c (finish_overlapped_socket, overlapped_socket_io):
+ replace ECONNABORTED to EPIPE in send, sendto and sendmsg to improve
+ BSD socket compatibility. this change removes a failure on the test
+ of net/ftp.
+
Wed May 23 05:35:58 2012 Eric Hodel <drbrain@segment7.net>
* lib/net/http.rb: Broke up Net::HTTP into individual files.
diff --git a/win32/win32.c b/win32/win32.c
index 16ec249..34c62fb 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -3084,7 +3084,7 @@ rb_w32_listen(int s, int backlog)
/* License: Ruby's */
static int
-finish_overlapped_socket(SOCKET s, WSAOVERLAPPED *wol, int result, DWORD *len, DWORD size)
+finish_overlapped_socket(BOOL input, SOCKET s, WSAOVERLAPPED *wol, int result, DWORD *len, DWORD size)
{
DWORD flg;
int err;
@@ -3103,7 +3103,10 @@ finish_overlapped_socket(SOCKET s, WSAOVERLAPPED *wol, int result, DWORD *len, D
}
/* thru */
default:
- errno = map_errno(WSAGetLastError());
+ if ((err = WSAGetLastError()) == WSAECONNABORTED && !input)
+ errno = EPIPE;
+ else
+ errno = map_errno(WSAGetLastError());
/* thru */
case WAIT_OBJECT_0 + 1:
/* interrupted */
@@ -3113,7 +3116,10 @@ finish_overlapped_socket(SOCKET s, WSAOVERLAPPED *wol, int result, DWORD *len, D
}
}
else {
- errno = map_errno(err);
+ if (err == WSAECONNABORTED && !input)
+ errno = EPIPE;
+ else
+ errno = map_errno(err);
*len = -1;
}
CloseHandle(wol->hEvent);
@@ -3146,15 +3152,22 @@ overlapped_socket_io(BOOL input, int fd, char *buf, int len, int flags,
r = recvfrom(s, buf, len, flags, addr, addrlen);
else
r = recv(s, buf, len, flags);
+ if (r == SOCKET_ERROR)
+ errno = map_errno(WSAGetLastError());
}
else {
if (addr && addrlen)
r = sendto(s, buf, len, flags, addr, *addrlen);
else
r = send(s, buf, len, flags);
+ if (r == SOCKET_ERROR) {
+ DWORD err = WSAGetLastError();
+ if (err == WSAECONNABORTED)
+ errno = EPIPE;
+ else
+ errno = map_errno(err);
+ }
}
- if (r == SOCKET_ERROR)
- errno = map_errno(WSAGetLastError());
});
}
else {
@@ -3182,7 +3195,7 @@ overlapped_socket_io(BOOL input, int fd, char *buf, int len, int flags,
}
});
- finish_overlapped_socket(s, &wol, ret, &rlen, size);
+ finish_overlapped_socket(input, s, &wol, ret, &rlen, size);
r = (int)rlen;
}
@@ -3300,7 +3313,7 @@ recvmsg(int fd, struct msghdr *msg, int flags)
ret = pWSARecvMsg(s, &wsamsg, &size, &wol, NULL);
});
- ret = finish_overlapped_socket(s, &wol, ret, &len, size);
+ ret = finish_overlapped_socket(TRUE, s, &wol, ret, &len, size);
}
if (ret == SOCKET_ERROR)
return -1;
@@ -3357,7 +3370,7 @@ sendmsg(int fd, const struct msghdr *msg, int flags)
ret = pWSASendMsg(s, &wsamsg, flags, &size, &wol, NULL);
});
- finish_overlapped_socket(s, &wol, ret, &len, size);
+ finish_overlapped_socket(FALSE, s, &wol, ret, &len, size);
}
return len;