summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Nagy <gabrielnagy@me.com>2019-10-11 07:48:02 +0300
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-10-11 13:48:02 +0900
commitddfb306e8e98282174cb078aa8e55aca223973ab (patch)
treef42174815410d8b8fe7ac87316f394c4571f3248
parent7cc1cd3d1ed1d482ea2ec247fa6a4ad0f044418a (diff)
win32.c: Remove unused calls to StartSockets (#2312)
NtSocketsInitialized behavior changed in e33b1690, requiring a call to rb_w32_sysinit for starting Windows Sockets. This commit removes NtSocketsInitialized entirely to avoid confusion. Signed-off-by: Gabriel Nagy <gabriel.nagy@puppet.com>
-rw-r--r--win32/win32.c77
1 files changed, 2 insertions, 75 deletions
diff --git a/win32/win32.c b/win32/win32.c
index 49137bcc6d..247ac918d4 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -689,7 +689,6 @@ rtc_error_handler(int e, const char *src, int line, const char *exe, const char
#endif
static CRITICAL_SECTION select_mutex;
-#define NtSocketsInitialized 1
static st_table *socklist = NULL;
static st_table *conlist = NULL;
#define conlist_disabled ((st_table *)-1)
@@ -728,10 +727,8 @@ constat_delete(HANDLE h)
static void
exit_handler(void)
{
- if (NtSocketsInitialized) {
- WSACleanup();
- DeleteCriticalSection(&select_mutex);
- }
+ WSACleanup();
+ DeleteCriticalSection(&select_mutex);
if (uenvarea) {
free(uenvarea);
uenvarea = NULL;
@@ -3054,9 +3051,6 @@ do_select(int nfds, fd_set *rd, fd_set *wr, fd_set *ex,
rb_w32_sleep(INFINITE);
}
else {
- if (!NtSocketsInitialized)
- StartSockets();
-
RUBY_CRITICAL {
EnterCriticalSection(&select_mutex);
r = select(nfds, rd, wr, ex, timeout);
@@ -3282,9 +3276,6 @@ rb_w32_accept(int s, struct sockaddr *addr, int *addrlen)
SOCKET r;
int fd;
- if (!NtSocketsInitialized) {
- StartSockets();
- }
RUBY_CRITICAL {
r = accept(TO_SOCKET(s), addr, addrlen);
if (r != INVALID_SOCKET) {
@@ -3311,9 +3302,6 @@ rb_w32_bind(int s, const struct sockaddr *addr, int addrlen)
{
int r;
- if (!NtSocketsInitialized) {
- StartSockets();
- }
RUBY_CRITICAL {
r = bind(TO_SOCKET(s), addr, addrlen);
if (r == SOCKET_ERROR)
@@ -3329,9 +3317,6 @@ int WSAAPI
rb_w32_connect(int s, const struct sockaddr *addr, int addrlen)
{
int r;
- if (!NtSocketsInitialized) {
- StartSockets();
- }
RUBY_CRITICAL {
r = connect(TO_SOCKET(s), addr, addrlen);
if (r == SOCKET_ERROR) {
@@ -3353,9 +3338,6 @@ int WSAAPI
rb_w32_getpeername(int s, struct sockaddr *addr, int *addrlen)
{
int r;
- if (!NtSocketsInitialized) {
- StartSockets();
- }
RUBY_CRITICAL {
r = getpeername(TO_SOCKET(s), addr, addrlen);
if (r == SOCKET_ERROR)
@@ -3372,9 +3354,6 @@ rb_w32_getsockname(int fd, struct sockaddr *addr, int *addrlen)
{
int sock;
int r;
- if (!NtSocketsInitialized) {
- StartSockets();
- }
RUBY_CRITICAL {
sock = TO_SOCKET(fd);
r = getsockname(sock, addr, addrlen);
@@ -3404,9 +3383,6 @@ int WSAAPI
rb_w32_getsockopt(int s, int level, int optname, char *optval, int *optlen)
{
int r;
- if (!NtSocketsInitialized) {
- StartSockets();
- }
RUBY_CRITICAL {
r = getsockopt(TO_SOCKET(s), level, optname, optval, optlen);
if (r == SOCKET_ERROR)
@@ -3422,9 +3398,6 @@ int WSAAPI
rb_w32_ioctlsocket(int s, long cmd, u_long *argp)
{
int r;
- if (!NtSocketsInitialized) {
- StartSockets();
- }
RUBY_CRITICAL {
r = ioctlsocket(TO_SOCKET(s), cmd, argp);
if (r == SOCKET_ERROR)
@@ -3440,9 +3413,6 @@ int WSAAPI
rb_w32_listen(int s, int backlog)
{
int r;
- if (!NtSocketsInitialized) {
- StartSockets();
- }
RUBY_CRITICAL {
r = listen(TO_SOCKET(s), backlog);
if (r == SOCKET_ERROR)
@@ -3521,9 +3491,6 @@ overlapped_socket_io(BOOL input, int fd, char *buf, int len, int flags,
WSABUF wbuf;
SOCKET s;
- if (!NtSocketsInitialized)
- StartSockets();
-
s = TO_SOCKET(fd);
socklist_lookup(s, &mode);
if (GET_FLAGS(mode) & O_NONBLOCK) {
@@ -3661,9 +3628,6 @@ recvmsg(int fd, struct msghdr *msg, int flags)
DWORD len;
int ret;
- if (!NtSocketsInitialized)
- StartSockets();
-
s = TO_SOCKET(fd);
if (!pWSARecvMsg) {
@@ -3719,9 +3683,6 @@ sendmsg(int fd, const struct msghdr *msg, int flags)
DWORD len;
int ret;
- if (!NtSocketsInitialized)
- StartSockets();
-
s = TO_SOCKET(fd);
if (!pWSASendMsg) {
@@ -3764,9 +3725,6 @@ int WSAAPI
rb_w32_setsockopt(int s, int level, int optname, const char *optval, int optlen)
{
int r;
- if (!NtSocketsInitialized) {
- StartSockets();
- }
RUBY_CRITICAL {
r = setsockopt(TO_SOCKET(s), level, optname, optval, optlen);
if (r == SOCKET_ERROR)
@@ -3782,9 +3740,6 @@ int WSAAPI
rb_w32_shutdown(int s, int how)
{
int r;
- if (!NtSocketsInitialized) {
- StartSockets();
- }
RUBY_CRITICAL {
r = shutdown(TO_SOCKET(s), how);
if (r == SOCKET_ERROR)
@@ -3852,9 +3807,6 @@ rb_w32_socket(int af, int type, int protocol)
SOCKET s;
int fd;
- if (!NtSocketsInitialized) {
- StartSockets();
- }
RUBY_CRITICAL {
s = open_ifs_socket(af, type, protocol);
if (s == INVALID_SOCKET) {
@@ -3879,9 +3831,6 @@ struct hostent * WSAAPI
rb_w32_gethostbyaddr(const char *addr, int len, int type)
{
struct hostent *r;
- if (!NtSocketsInitialized) {
- StartSockets();
- }
RUBY_CRITICAL {
r = gethostbyaddr(addr, len, type);
if (r == NULL)
@@ -3897,9 +3846,6 @@ struct hostent * WSAAPI
rb_w32_gethostbyname(const char *name)
{
struct hostent *r;
- if (!NtSocketsInitialized) {
- StartSockets();
- }
RUBY_CRITICAL {
r = gethostbyname(name);
if (r == NULL)
@@ -3915,9 +3861,6 @@ int WSAAPI
rb_w32_gethostname(char *name, int len)
{
int r;
- if (!NtSocketsInitialized) {
- StartSockets();
- }
RUBY_CRITICAL {
r = gethostname(name, len);
if (r == SOCKET_ERROR)
@@ -3933,9 +3876,6 @@ struct protoent * WSAAPI
rb_w32_getprotobyname(const char *name)
{
struct protoent *r;
- if (!NtSocketsInitialized) {
- StartSockets();
- }
RUBY_CRITICAL {
r = getprotobyname(name);
if (r == NULL)
@@ -3951,9 +3891,6 @@ struct protoent * WSAAPI
rb_w32_getprotobynumber(int num)
{
struct protoent *r;
- if (!NtSocketsInitialized) {
- StartSockets();
- }
RUBY_CRITICAL {
r = getprotobynumber(num);
if (r == NULL)
@@ -3969,9 +3906,6 @@ struct servent * WSAAPI
rb_w32_getservbyname(const char *name, const char *proto)
{
struct servent *r;
- if (!NtSocketsInitialized) {
- StartSockets();
- }
RUBY_CRITICAL {
r = getservbyname(name, proto);
if (r == NULL)
@@ -3987,9 +3921,6 @@ struct servent * WSAAPI
rb_w32_getservbyport(int port, const char *proto)
{
struct servent *r;
- if (!NtSocketsInitialized) {
- StartSockets();
- }
RUBY_CRITICAL {
r = getservbyport(port, proto);
if (r == NULL)
@@ -4011,10 +3942,6 @@ socketpair_internal(int af, int type, int protocol, SOCKET *sv)
int ret = -1;
int len;
- if (!NtSocketsInitialized) {
- StartSockets();
- }
-
switch (af) {
case AF_INET:
#if defined PF_INET && PF_INET != AF_INET