summaryrefslogtreecommitdiff
path: root/win32/win32.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-16 11:00:07 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-16 11:00:07 +0000
commit4eb4f1fd7e267eee38ed4d402c2cdd7f85532d6b (patch)
tree49c7fbf511786ddce61c5e74564d9c00e968d1c8 /win32/win32.c
parent23c5aa3a2c41fb5ef0b5c09f6d294ebe8dd4f157 (diff)
* 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.c29
1 files changed, 11 insertions, 18 deletions
diff --git a/win32/win32.c b/win32/win32.c
index 55e0d2e..e17d35b 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;
}