Bug #2632 » winsock2.patch
win32/win32.c (working copy) | ||
---|---|---|
});
|
||
return r;
|
||
}
|
||
|
||
static void
|
||
socket_clear(int fd)
|
||
{
|
||
char buf[256];
|
||
if (fcntl(fd, F_SETFL, O_NONBLOCK) != -1) {
|
||
while ((ssize_t)rb_w32_read(fd, buf, sizeof(buf)) > 0);
|
||
} else {
|
||
struct timeval timeout = {0, 0};
|
||
while(select(2, &fd, 0, 0, &timeout) > 0) {
|
||
rb_w32_read(fd, buf, sizeof(buf));
|
||
}
|
||
}
|
||
}
|
||
#undef shutdown
|
||
int WSAAPI
|
||
... | ... | |
if (!NtSocketsInitialized) {
|
||
StartSockets();
|
||
}
|
||
if (how == SD_RECEIVE || how == SD_BOTH) {
|
||
socket_clear(s);
|
||
}
|
||
RUBY_CRITICAL({
|
||
r = shutdown(TO_SOCKET(s), how);
|
||
if (r == SOCKET_ERROR)
|
||
... | ... | |
UnlockFile((HANDLE)sock, 0, 0, LK_LEN, LK_LEN);
|
||
return _close(fd);
|
||
}
|
||
socket_clear(fd);
|
||
_set_osfhnd(fd, (SOCKET)INVALID_HANDLE_VALUE);
|
||
key = (st_data_t)sock;
|
||
st_delete(socklist, &key, NULL);
|
- « Previous
- 1
- 2
- Next »