Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

* 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
  • Loading branch information...
commit 87c8c5edf43a7f7d33d5fe75f51ef410a03b93b1 1 parent 510bbe0
unak unak authored

Showing 2 changed files with 28 additions and 8 deletions. Show diff stats Hide diff stats

  1. +7 0 ChangeLog
  2. +21 8 win32/win32.c
7 ChangeLog
... ... @@ -1,3 +1,10 @@
  1 +Wed May 23 10:18:54 2012 NAKAMURA Usaku <usa@ruby-lang.org>
  2 +
  3 + * win32/win32.c (finish_overlapped_socket, overlapped_socket_io):
  4 + replace ECONNABORTED to EPIPE in send, sendto and sendmsg to improve
  5 + BSD socket compatibility. this change removes a failure on the test
  6 + of net/ftp.
  7 +
1 8 Wed May 23 05:35:58 2012 Eric Hodel <drbrain@segment7.net>
2 9
3 10 * lib/net/http.rb: Broke up Net::HTTP into individual files.
29 win32/win32.c
@@ -3084,7 +3084,7 @@ rb_w32_listen(int s, int backlog)
3084 3084
3085 3085 /* License: Ruby's */
3086 3086 static int
3087   -finish_overlapped_socket(SOCKET s, WSAOVERLAPPED *wol, int result, DWORD *len, DWORD size)
  3087 +finish_overlapped_socket(BOOL input, SOCKET s, WSAOVERLAPPED *wol, int result, DWORD *len, DWORD size)
3088 3088 {
3089 3089 DWORD flg;
3090 3090 int err;
@@ -3103,7 +3103,10 @@ finish_overlapped_socket(SOCKET s, WSAOVERLAPPED *wol, int result, DWORD *len, D
3103 3103 }
3104 3104 /* thru */
3105 3105 default:
3106   - errno = map_errno(WSAGetLastError());
  3106 + if ((err = WSAGetLastError()) == WSAECONNABORTED && !input)
  3107 + errno = EPIPE;
  3108 + else
  3109 + errno = map_errno(WSAGetLastError());
3107 3110 /* thru */
3108 3111 case WAIT_OBJECT_0 + 1:
3109 3112 /* interrupted */
@@ -3113,7 +3116,10 @@ finish_overlapped_socket(SOCKET s, WSAOVERLAPPED *wol, int result, DWORD *len, D
3113 3116 }
3114 3117 }
3115 3118 else {
3116   - errno = map_errno(err);
  3119 + if (err == WSAECONNABORTED && !input)
  3120 + errno = EPIPE;
  3121 + else
  3122 + errno = map_errno(err);
3117 3123 *len = -1;
3118 3124 }
3119 3125 CloseHandle(wol->hEvent);
@@ -3146,15 +3152,22 @@ overlapped_socket_io(BOOL input, int fd, char *buf, int len, int flags,
3146 3152 r = recvfrom(s, buf, len, flags, addr, addrlen);
3147 3153 else
3148 3154 r = recv(s, buf, len, flags);
  3155 + if (r == SOCKET_ERROR)
  3156 + errno = map_errno(WSAGetLastError());
3149 3157 }
3150 3158 else {
3151 3159 if (addr && addrlen)
3152 3160 r = sendto(s, buf, len, flags, addr, *addrlen);
3153 3161 else
3154 3162 r = send(s, buf, len, flags);
  3163 + if (r == SOCKET_ERROR) {
  3164 + DWORD err = WSAGetLastError();
  3165 + if (err == WSAECONNABORTED)
  3166 + errno = EPIPE;
  3167 + else
  3168 + errno = map_errno(err);
  3169 + }
3155 3170 }
3156   - if (r == SOCKET_ERROR)
3157   - errno = map_errno(WSAGetLastError());
3158 3171 });
3159 3172 }
3160 3173 else {
@@ -3182,7 +3195,7 @@ overlapped_socket_io(BOOL input, int fd, char *buf, int len, int flags,
3182 3195 }
3183 3196 });
3184 3197
3185   - finish_overlapped_socket(s, &wol, ret, &rlen, size);
  3198 + finish_overlapped_socket(input, s, &wol, ret, &rlen, size);
3186 3199 r = (int)rlen;
3187 3200 }
3188 3201
@@ -3300,7 +3313,7 @@ recvmsg(int fd, struct msghdr *msg, int flags)
3300 3313 ret = pWSARecvMsg(s, &wsamsg, &size, &wol, NULL);
3301 3314 });
3302 3315
3303   - ret = finish_overlapped_socket(s, &wol, ret, &len, size);
  3316 + ret = finish_overlapped_socket(TRUE, s, &wol, ret, &len, size);
3304 3317 }
3305 3318 if (ret == SOCKET_ERROR)
3306 3319 return -1;
@@ -3357,7 +3370,7 @@ sendmsg(int fd, const struct msghdr *msg, int flags)
3357 3370 ret = pWSASendMsg(s, &wsamsg, flags, &size, &wol, NULL);
3358 3371 });
3359 3372
3360   - finish_overlapped_socket(s, &wol, ret, &len, size);
  3373 + finish_overlapped_socket(FALSE, s, &wol, ret, &len, size);
3361 3374 }
3362 3375
3363 3376 return len;

0 comments on commit 87c8c5e

Please sign in to comment.
Something went wrong with that request. Please try again.