diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2014-04-15 17:25:42 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2014-04-15 17:25:42 +0000 |
commit | 9c46e5f86cd4453c3060f281f9a85641f750eff5 (patch) | |
tree | 23f8234a57d37fa3e4571a0ac68199ed63f16e5e | |
parent | f85a644b92f33931bdffb92eae72b6eb6fcda9db (diff) |
Toss a `unifdef -U OPENSSL_SYS_WINDOWS' bomb into crypto/bio.
ok miod@
-rw-r--r-- | lib/libcrypto/bio/b_sock.c | 38 | ||||
-rw-r--r-- | lib/libcrypto/bio/bss_dgram.c | 114 | ||||
-rw-r--r-- | lib/libcrypto/bio/bss_fd.c | 6 | ||||
-rw-r--r-- | lib/libcrypto/bio/bss_file.c | 8 | ||||
-rw-r--r-- | lib/libcrypto/bio/bss_sock.c | 6 |
5 files changed, 3 insertions, 169 deletions
diff --git a/lib/libcrypto/bio/b_sock.c b/lib/libcrypto/bio/b_sock.c index d7394525805..2a9159ec558 100644 --- a/lib/libcrypto/bio/b_sock.c +++ b/lib/libcrypto/bio/b_sock.c @@ -457,27 +457,6 @@ end: int BIO_sock_init(void) { -#ifdef OPENSSL_SYS_WINDOWS - static struct WSAData wsa_state; - - if (!wsa_init_done) { - int err; - - wsa_init_done = 1; - memset(&wsa_state, 0, sizeof(wsa_state)); - /* Not making wsa_state available to the rest of the - * code is formally wrong. But the structures we use - * are [beleived to be] invariable among Winsock DLLs, - * while API availability is [expected to be] probed - * at run-time with DSO_global_lookup. */ - if (WSAStartup(0x0202, &wsa_state) != 0) { - err = WSAGetLastError(); - SYSerr(SYS_F_WSASTARTUP, err); - BIOerr(BIO_F_BIO_SOCK_INIT, BIO_R_WSASTARTUP); - return (-1); - } - } -#endif /* OPENSSL_SYS_WINDOWS */ #ifdef WATT32 extern int _watt_do_exit; _watt_do_exit = 0; @@ -509,15 +488,7 @@ BIO_sock_init(void) void BIO_sock_cleanup(void) { -#ifdef OPENSSL_SYS_WINDOWS - if (wsa_init_done) { - wsa_init_done = 0; -#if 0 /* this call is claimed to be non-present in Winsock2 */ - WSACancelBlockingCall(); -#endif - WSACleanup(); - } -#elif defined(OPENSSL_SYS_NETWARE) && !defined(NETWARE_BSDSOCK) +#if defined(OPENSSL_SYS_NETWARE) && !defined(NETWARE_BSDSOCK) if (wsa_init_done) { wsa_init_done = 0; WSACleanup(); @@ -738,14 +709,7 @@ again: #ifdef SO_REUSEADDR err_num = errno; if ((bind_mode == BIO_BIND_REUSEADDR_IF_UNUSED) && -#ifdef OPENSSL_SYS_WINDOWS - /* Some versions of Windows define EADDRINUSE to - * a dummy value. - */ - (err_num == WSAEADDRINUSE)) -#else (err_num == EADDRINUSE)) -#endif { client = server; if (h == NULL || strcmp(h, "*") == 0) { diff --git a/lib/libcrypto/bio/bss_dgram.c b/lib/libcrypto/bio/bss_dgram.c index 330f6fc404e..328bab9ce3c 100644 --- a/lib/libcrypto/bio/bss_dgram.c +++ b/lib/libcrypto/bio/bss_dgram.c @@ -279,25 +279,12 @@ dgram_adjust_rcv_timeout(BIO *b) struct timeval timenow, timeleft; /* Read current socket timeout */ -#ifdef OPENSSL_SYS_WINDOWS - int timeout; - - sz.i = sizeof(timeout); - if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, - (void*)&timeout, &sz.i) < 0) { - perror("getsockopt"); - } else { - data->socket_timeout.tv_sec = timeout / 1000; - data->socket_timeout.tv_usec = (timeout % 1000) * 1000; - } -#else sz.i = sizeof(data->socket_timeout); if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, &(data->socket_timeout), (void *)&sz) < 0) { perror("getsockopt"); } else if (sizeof(sz.s) != sizeof(sz.i) && sz.i == 0) OPENSSL_assert(sz.s <= sizeof(data->socket_timeout)); -#endif /* Get current time */ get_current_time(&timenow); @@ -324,18 +311,10 @@ dgram_adjust_rcv_timeout(BIO *b) (data->socket_timeout.tv_sec > timeleft.tv_sec) || (data->socket_timeout.tv_sec == timeleft.tv_sec && data->socket_timeout.tv_usec >= timeleft.tv_usec)) { -#ifdef OPENSSL_SYS_WINDOWS - timeout = timeleft.tv_sec * 1000 + timeleft.tv_usec / 1000; - if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, - (void*)&timeout, sizeof(timeout)) < 0) { - perror("setsockopt"); - } -#else if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, &timeleft, sizeof(struct timeval)) < 0) { perror("setsockopt"); } -#endif } } #endif @@ -349,19 +328,10 @@ dgram_reset_rcv_timeout(BIO *b) /* Is a timer active? */ if (data->next_timeout.tv_sec > 0 || data->next_timeout.tv_usec > 0) { -#ifdef OPENSSL_SYS_WINDOWS - int timeout = data->socket_timeout.tv_sec * 1000 + - data->socket_timeout.tv_usec / 1000; - if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, - (void*)&timeout, sizeof(timeout)) < 0) { - perror("setsockopt"); - } -#else if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, &(data->socket_timeout), sizeof(struct timeval)) < 0) { perror("setsockopt"); } -#endif } #endif } @@ -716,23 +686,11 @@ default: break; #if defined(SO_RCVTIMEO) case BIO_CTRL_DGRAM_SET_RECV_TIMEOUT: -#ifdef OPENSSL_SYS_WINDOWS - { - struct timeval *tv = (struct timeval *)ptr; - int timeout = tv->tv_sec * 1000 + tv->tv_usec/1000; - if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, - (void*)&timeout, sizeof(timeout)) < 0) { - perror("setsockopt"); - ret = -1; - } - } -#else if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, ptr, sizeof(struct timeval)) < 0) { perror("setsockopt"); ret = -1; } -#endif break; case BIO_CTRL_DGRAM_GET_RECV_TIMEOUT: { @@ -740,21 +698,6 @@ default: size_t s; int i; } sz = {0}; -#ifdef OPENSSL_SYS_WINDOWS - int timeout; - struct timeval *tv = (struct timeval *)ptr; - - sz.i = sizeof(timeout); - if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, - (void*)&timeout, &sz.i) < 0) { - perror("getsockopt"); - ret = -1; - } else { - tv->tv_sec = timeout / 1000; - tv->tv_usec = (timeout % 1000) * 1000; - ret = sizeof(*tv); - } -#else sz.i = sizeof(struct timeval); if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, ptr, (void *)&sz) < 0) { @@ -765,29 +708,16 @@ default: ret = (int)sz.s; } else ret = sz.i; -#endif } break; #endif #if defined(SO_SNDTIMEO) case BIO_CTRL_DGRAM_SET_SEND_TIMEOUT: -#ifdef OPENSSL_SYS_WINDOWS - { - struct timeval *tv = (struct timeval *)ptr; - int timeout = tv->tv_sec * 1000 + tv->tv_usec/1000; - if (setsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO, - (void*)&timeout, sizeof(timeout)) < 0) { - perror("setsockopt"); - ret = -1; - } - } -#else if (setsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO, ptr, sizeof(struct timeval)) < 0) { perror("setsockopt"); ret = -1; } -#endif break; case BIO_CTRL_DGRAM_GET_SEND_TIMEOUT: { @@ -795,21 +725,6 @@ default: size_t s; int i; } sz = {0}; -#ifdef OPENSSL_SYS_WINDOWS - int timeout; - struct timeval *tv = (struct timeval *)ptr; - - sz.i = sizeof(timeout); - if (getsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO, - (void*)&timeout, &sz.i) < 0) { - perror("getsockopt"); - ret = -1; - } else { - tv->tv_sec = timeout / 1000; - tv->tv_usec = (timeout % 1000) * 1000; - ret = sizeof(*tv); - } -#else sz.i = sizeof(struct timeval); if (getsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO, ptr, (void *)&sz) < 0) { @@ -820,19 +735,13 @@ default: ret = (int)sz.s; } else ret = sz.i; -#endif } break; #endif case BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP: /* fall-through */ case BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP: -#ifdef OPENSSL_SYS_WINDOWS - if (data->_errno == WSAETIMEDOUT) -#else - if (data->_errno == EAGAIN) -#endif - { + if (data->_errno == EAGAIN) { ret = 1; data->_errno = 0; } else @@ -1769,16 +1678,6 @@ BIO_dgram_should_retry(int i) if ((i == 0) || (i == -1)) { err = errno; - -#if defined(OPENSSL_SYS_WINDOWS) - /* If the socket return value (i) is -1 - * and err is unexpectedly 0 at this point, - * the error code was overwritten by - * another system call before this error - * handling is called. - */ -#endif - return (BIO_dgram_non_fatal_error(err)); } return (0); @@ -1788,17 +1687,6 @@ int BIO_dgram_non_fatal_error(int err) { switch (err) { -#if defined(OPENSSL_SYS_WINDOWS) -# if defined(WSAEWOULDBLOCK) - case WSAEWOULDBLOCK: -# endif - -# if 0 /* This appears to always be an error */ -# if defined(WSAENOTCONN) - case WSAENOTCONN: -# endif -# endif -#endif #ifdef EWOULDBLOCK # ifdef WSAEWOULDBLOCK diff --git a/lib/libcrypto/bio/bss_fd.c b/lib/libcrypto/bio/bss_fd.c index 35ddd61359a..86757154e8a 100644 --- a/lib/libcrypto/bio/bss_fd.c +++ b/lib/libcrypto/bio/bss_fd.c @@ -261,12 +261,6 @@ BIO_fd_should_retry(int i) if ((i == 0) || (i == -1)) { err = errno; - -#if defined(OPENSSL_SYS_WINDOWS) && 0 /* more microsoft stupidity? perhaps not? Ben 4/1/99 */ - if ((i == -1) && (err == 0)) - return (1); -#endif - return (BIO_fd_non_fatal_error(err)); } return (0); diff --git a/lib/libcrypto/bio/bss_file.c b/lib/libcrypto/bio/bss_file.c index 794f503a695..982317b34a5 100644 --- a/lib/libcrypto/bio/bss_file.c +++ b/lib/libcrypto/bio/bss_file.c @@ -320,13 +320,7 @@ file_ctrl(BIO *b, int cmd, long num, void *ptr) else #endif { -#if defined(OPENSSL_SYS_WINDOWS) - int fd = _fileno((FILE*)ptr); - if (num & BIO_FP_TEXT) - _setmode(fd, _O_TEXT); - else - _setmode(fd, _O_BINARY); -#elif defined(OPENSSL_SYS_NETWARE) && defined(NETWARE_CLIB) +#if defined(OPENSSL_SYS_NETWARE) && defined(NETWARE_CLIB) int fd = fileno((FILE*)ptr); /* Under CLib there are differences in file modes */ if (num & BIO_FP_TEXT) diff --git a/lib/libcrypto/bio/bss_sock.c b/lib/libcrypto/bio/bss_sock.c index f6d3bf73659..30640d8f962 100644 --- a/lib/libcrypto/bio/bss_sock.c +++ b/lib/libcrypto/bio/bss_sock.c @@ -224,12 +224,6 @@ BIO_sock_should_retry(int i) if ((i == 0) || (i == -1)) { err = errno; - -#if defined(OPENSSL_SYS_WINDOWS) && 0 /* more microsoft stupidity? perhaps not? Ben 4/1/99 */ - if ((i == -1) && (err == 0)) - return (1); -#endif - return (BIO_sock_non_fatal_error(err)); } return (0); |