1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* win32/win32.c (rb_w32_accept): simplified.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
usa 2015-05-16 11:00:07 +00:00
parent 23c5aa3a2c
commit 4eb4f1fd7e
2 changed files with 15 additions and 18 deletions

View file

@ -1,3 +1,7 @@
Sat May 16 19:59:24 2015 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/win32.c (rb_w32_accept): simplified.
Fri May 15 18:28:20 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
* array.c (rb_ary_assoc, rb_ary_rassoc): [DOC] the result when key

View file

@ -3027,26 +3027,19 @@ rb_w32_accept(int s, struct sockaddr *addr, int *addrlen)
StartSockets();
}
RUBY_CRITICAL({
HANDLE h = CreateFile("NUL", 0, 0, NULL, OPEN_ALWAYS, 0, NULL);
fd = rb_w32_open_osfhandle((intptr_t)h, O_RDWR|O_BINARY|O_NOINHERIT);
if (fd != -1) {
r = accept(TO_SOCKET(s), addr, addrlen);
if (r != INVALID_SOCKET) {
SetHandleInformation((HANDLE)r, HANDLE_FLAG_INHERIT, 0);
rb_acrt_lowio_lock_fh(fd);
_set_osfhnd(fd, r);
rb_acrt_lowio_unlock_fh(fd);
CloseHandle(h);
r = accept(TO_SOCKET(s), addr, addrlen);
if (r != INVALID_SOCKET) {
SetHandleInformation((HANDLE)r, HANDLE_FLAG_INHERIT, 0);
fd = rb_w32_open_osfhandle((intptr_t)r, O_RDWR|O_BINARY|O_NOINHERIT);
if (fd != -1)
socklist_insert(r, 0);
}
else {
errno = map_errno(WSAGetLastError());
close(fd);
fd = -1;
}
else
closesocket(r);
}
else {
errno = map_errno(WSAGetLastError());
fd = -1;
}
else
CloseHandle(h);
});
return fd;
}