diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-05-16 11:00:07 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-05-16 11:00:07 +0000 |
commit | 3404ba46a0ad73302a1d1e114bffadd19683f1e1 (patch) | |
tree | 49c7fbf511786ddce61c5e74564d9c00e968d1c8 /win32/win32.c | |
parent | 8074a8a8e965fe706a7f2223669cb1a1c132fcde (diff) | |
download | ruby-3404ba46a0ad73302a1d1e114bffadd19683f1e1.tar.gz |
* win32/win32.c (rb_w32_accept): simplified.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32/win32.c')
-rw-r--r-- | win32/win32.c | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/win32/win32.c b/win32/win32.c index 55e0d2e94a..e17d35b0c2 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -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; } |