From: Ralf S. Engelschall Date: Sat, 5 May 2001 16:35:18 +0000 (+0000) Subject: Axe most WIN32 stuff from Apache 1.3. In Apache 2.0 we either use APR X-Git-Tag: 2.0.18~92 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4f6be425bef72ba429bc39befbfa1b7a6c673635;p=apache Axe most WIN32 stuff from Apache 1.3. In Apache 2.0 we either use APR later for this or we don't do it at all. But we certainly no longer want to see any platform specific things inside a module. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@89018 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/ssl/mod_ssl.h b/modules/ssl/mod_ssl.h index 59c40b776c..5e9b48fdc3 100644 --- a/modules/ssl/mod_ssl.h +++ b/modules/ssl/mod_ssl.h @@ -97,13 +97,7 @@ #include #include #include -#ifndef WIN32 #include -#endif -#ifdef WIN32 -#include -#include -#endif /* OpenSSL headers */ #include @@ -257,7 +251,7 @@ #endif #if !defined(SSL_USE_FCNTL) && !defined(SSL_USE_FLOCK) #define SSL_USE_FLOCK 1 -#if !defined(MPE) && !defined(WIN32) +#if !defined(MPE) #include #endif #ifndef LOCK_UN @@ -275,11 +269,7 @@ /* * Support for Mutex */ -#ifndef WIN32 #define SSL_MUTEX_LOCK_MODE ( S_IRUSR|S_IWUSR ) -#else -#define SSL_MUTEX_LOCK_MODE (_S_IREAD|_S_IWRITE ) -#endif #if defined(USE_SYSVSEM_SERIALIZED_ACCEPT) ||\ (defined(__FreeBSD__) && defined(__FreeBSD_version) &&\ __FreeBSD_version >= 300000) ||\ @@ -305,30 +295,16 @@ union ssl_ipc_semun { unsigned short int *array; }; #endif -#ifdef WIN32 -#define SSL_CAN_USE_SEM -#define SSL_HAVE_W32SEM -#include "multithread.h" -#include -#endif /* * Support for MM library */ -#ifndef WIN32 #define SSL_MM_FILE_MODE ( S_IRUSR|S_IWUSR ) -#else -#define SSL_MM_FILE_MODE ( _S_IREAD|_S_IWRITE ) -#endif /* * Support for DBM library */ -#ifndef WIN32 #define SSL_DBM_FILE_MODE ( S_IRUSR|S_IWUSR ) -#else -#define SSL_DBM_FILE_MODE ( _S_IREAD|_S_IWRITE ) -#endif #if !defined(SSL_DBM_FILE_SUFFIX_DIR) && !defined(SSL_DBM_FILE_SUFFIX_PAG) #if defined(DBM_SUFFIX) diff --git a/modules/ssl/ssl_engine_config.c b/modules/ssl/ssl_engine_config.c index 538c900a0c..8725a37ded 100644 --- a/modules/ssl/ssl_engine_config.c +++ b/modules/ssl/ssl_engine_config.c @@ -342,14 +342,10 @@ const char *ssl_cmd_SSLMutex( mc->nMutexMode = SSL_MUTEXMODE_NONE; } else if (strlen(arg) > 5 && strcEQn(arg, "file:", 5)) { -#ifndef WIN32 mc->nMutexMode = SSL_MUTEXMODE_FILE; mc->szMutexFile = ap_psprintf(mc->pPool, "%s.%lu", ap_server_root_relative(cmd->pool, "mutex", arg+5), (unsigned long)getpid()); -#else - return "SSLMutex: Lockfiles not available on this platform"; -#endif } else if (strcEQ(arg, "sem")) { #ifdef SSL_CAN_USE_SEM diff --git a/modules/ssl/ssl_engine_init.c b/modules/ssl/ssl_engine_init.c index 3d542a635e..777662cb37 100644 --- a/modules/ssl/ssl_engine_init.c +++ b/modules/ssl/ssl_engine_init.c @@ -127,11 +127,6 @@ void ssl_init_Module(server_rec *s, pool *p) SERVER_BASEVERSION, ssl_var_lookup(p, NULL, NULL, NULL, "SSL_VERSION_INTERFACE"), ssl_var_lookup(p, NULL, NULL, NULL, "SSL_VERSION_LIBRARY")); -#ifdef WIN32 - ssl_log(s, SSL_LOG_WARN, "You are using mod_ssl under Win32. " - "This combination is *NOT* officially supported. " - "Use it at your own risk!"); -#endif } /* @@ -194,9 +189,7 @@ void ssl_init_Module(server_rec *s, pool *p) if (mc->nInitCount == 1) { ssl_pphrase_Handle(s, p); ssl_init_TmpKeysHandle(SSL_TKP_GEN, s, p); -#ifndef WIN32 return; -#endif } /* diff --git a/modules/ssl/ssl_engine_io.c b/modules/ssl/ssl_engine_io.c index e56901415e..c747208afc 100644 --- a/modules/ssl/ssl_engine_io.c +++ b/modules/ssl/ssl_engine_io.c @@ -80,10 +80,6 @@ static int ssl_io_hook_write(BUFF *fb, char *buf, int len); #ifndef NO_WRITEV static int ssl_io_hook_writev(BUFF *fb, const struct iovec *iov, int iovcnt); #endif -#ifdef WIN32 -static int ssl_io_hook_recvwithtimeout(BUFF *fb, char *buf, int len); -static int ssl_io_hook_sendwithtimeout(BUFF *fb, const char *buf, int len); -#endif /* WIN32 */ void ssl_io_register(void) { @@ -91,12 +87,6 @@ void ssl_io_register(void) ap_hook_register("ap::buff::write", ssl_io_hook_write, AP_HOOK_NOCTX); #ifndef NO_WRITEV ap_hook_register("ap::buff::writev", ssl_io_hook_writev, AP_HOOK_NOCTX); -#endif -#ifdef WIN32 - ap_hook_register("ap::buff::recvwithtimeout", - ssl_io_hook_recvwithtimeout, AP_HOOK_NOCTX); - ap_hook_register("ap::buff::sendwithtimeout", - ssl_io_hook_sendwithtimeout, AP_HOOK_NOCTX); #endif return; } @@ -107,10 +97,6 @@ void ssl_io_unregister(void) ap_hook_unregister("ap::buff::write", ssl_io_hook_write); #ifndef NO_WRITEV ap_hook_unregister("ap::buff::writev", ssl_io_hook_writev); -#endif -#ifdef WIN32 - ap_hook_unregister("ap::buff::recvwithtimeout", ssl_io_hook_recvwithtimeout); - ap_hook_unregister("ap::buff::sendwithtimeout", ssl_io_hook_sendwithtimeout); #endif return; } @@ -218,173 +204,12 @@ static int ssl_io_hook_writev(BUFF *fb, const struct iovec *iov, int iovcnt) } #endif -#ifdef WIN32 - -/* these two functions are exported from buff.c under WIN32 */ -API_EXPORT(int) sendwithtimeout(int sock, const char *buf, int len, int flags); -API_EXPORT(int) recvwithtimeout(int sock, char *buf, int len, int flags); - -/* and the prototypes for our SSL_xxx variants */ -static int SSL_sendwithtimeout(BUFF *fb, const char *buf, int len); -static int SSL_recvwithtimeout(BUFF *fb, char *buf, int len); - -static int ssl_io_hook_recvwithtimeout(BUFF *fb, char *buf, int len) -{ - SSL *ssl; - int rc; - - if ((ssl = ap_ctx_get(fb->ctx, "ssl")) != NULL) - rc = SSL_recvwithtimeout(fb, buf, len); - else - rc = recvwithtimeout(fb->fd, buf, len, 0); - return rc; -} - -static int ssl_io_hook_sendwithtimeout(BUFF *fb, const char *buf, int len) -{ - SSL *ssl; - int rc; - - if ((ssl = ap_ctx_get(fb->ctx, "ssl")) != NULL) - rc = SSL_sendwithtimeout(fb, buf, len); - else - rc = sendwithtimeout(fb->fd, buf, len, 0); - return rc; -} - -#endif /* WIN32 */ - /* _________________________________________________________________ ** ** Special Functions for OpenSSL ** _________________________________________________________________ */ -#ifdef WIN32 - -static int SSL_sendwithtimeout(BUFF *fb, const char *buf, int len) -{ - int iostate = 1; - fd_set fdset; - struct timeval tv; - int err = WSAEWOULDBLOCK; - int rv; - int retry; - int sock = fb->fd; - SSL *ssl; - - ssl = ap_ctx_get(fb->ctx, "ssl"); - - if (!(tv.tv_sec = ap_check_alarm())) - return (SSL_write(ssl, (char*)buf, len)); - - rv = ioctlsocket(sock, FIONBIO, &iostate); - iostate = 0; - if (rv) { - err = WSAGetLastError(); - ap_assert(0); - } - rv = SSL_write(ssl, (char*)buf, len); - if (rv <= 0) { - if (BIO_sock_should_retry(rv)) { - do { - retry = 0; - FD_ZERO(&fdset); - FD_SET((unsigned int)sock, &fdset); - tv.tv_usec = 0; - rv = select(FD_SETSIZE, NULL, &fdset, NULL, &tv); - if (rv == SOCKET_ERROR) - err = WSAGetLastError(); - else if (rv == 0) { - ioctlsocket(sock, FIONBIO, &iostate); - if(ap_check_alarm() < 0) { - WSASetLastError(EINTR); /* Simulate an alarm() */ - return (SOCKET_ERROR); - } - } - else { - rv = SSL_write(ssl, (char*)buf, len); - if (BIO_sock_should_retry(rv)) { - ap_log_error(APLOG_MARK,APLOG_DEBUG, NULL, - "select claimed we could write, " - "but in fact we couldn't. " - "This is a bug in Windows."); - retry = 1; - Sleep(100); - } - } - } while(retry); - } - } - ioctlsocket(sock, FIONBIO, &iostate); - if (rv == SOCKET_ERROR) - WSASetLastError(err); - return (rv); -} - -static int SSL_recvwithtimeout(BUFF *fb, char *buf, int len) -{ - int iostate = 1; - fd_set fdset; - struct timeval tv; - int err = WSAEWOULDBLOCK; - int rv; - int sock = fb->fd_in; - SSL *ssl; - int retry; - - ssl = ap_ctx_get(fb->ctx, "ssl"); - - if (!(tv.tv_sec = ap_check_alarm())) - return (SSL_read(ssl, buf, len)); - - rv = ioctlsocket(sock, FIONBIO, &iostate); - iostate = 0; - ap_assert(!rv); - rv = SSL_read(ssl, buf, len); - if (rv <= 0) { - if (BIO_sock_should_retry(rv)) { - do { - retry = 0; - FD_ZERO(&fdset); - FD_SET((unsigned int)sock, &fdset); - tv.tv_usec = 0; - rv = select(FD_SETSIZE, &fdset, NULL, NULL, &tv); - if (rv == SOCKET_ERROR) - err = WSAGetLastError(); - else if (rv == 0) { - ioctlsocket(sock, FIONBIO, &iostate); - ap_check_alarm(); - WSASetLastError(WSAEWOULDBLOCK); - return (SOCKET_ERROR); - } - else { - rv = SSL_read(ssl, buf, len); - if (rv == SOCKET_ERROR) { - if (BIO_sock_should_retry(rv)) { - ap_log_error(APLOG_MARK,APLOG_DEBUG, NULL, - "select claimed we could read, " - "but in fact we couldn't. " - "This is a bug in Windows."); - retry = 1; - Sleep(100); - } - else { - err = WSAGetLastError(); - } - } - } - } while(retry); - } - } - ioctlsocket(sock, FIONBIO, &iostate); - if (rv == SOCKET_ERROR) - WSASetLastError(err); - return (rv); -} - -#endif /*WIN32*/ - /* * There is no SSL_writev() provided by OpenSSL. The reason is mainly because * OpenSSL has to fragment the data itself again for the SSL record layer, so a diff --git a/modules/ssl/ssl_engine_kernel.c b/modules/ssl/ssl_engine_kernel.c index 5566c9b64f..c1b37126cb 100644 --- a/modules/ssl/ssl_engine_kernel.c +++ b/modules/ssl/ssl_engine_kernel.c @@ -359,12 +359,8 @@ void ssl_hook_NewConnection(conn_rec *conn) /* * Improve I/O throughput by using * OpenSSL's read-ahead functionality - * (don't used under Win32, because - * there we use select()) */ -#ifndef WIN32 SSL_set_read_ahead(ssl, TRUE); -#endif return; } diff --git a/modules/ssl/ssl_engine_mutex.c b/modules/ssl/ssl_engine_mutex.c index afd4c512b3..d2ac555e38 100644 --- a/modules/ssl/ssl_engine_mutex.c +++ b/modules/ssl/ssl_engine_mutex.c @@ -140,7 +140,6 @@ void ssl_mutex_kill(server_rec *s) void ssl_mutex_file_create(server_rec *s, pool *p) { -#ifndef WIN32 SSLModConfigRec *mc = myModConfig(); /* create the lockfile */ @@ -168,13 +167,11 @@ void ssl_mutex_file_create(server_rec *s, pool *p) mc->szMutexFile); ssl_die(); } -#endif return; } void ssl_mutex_file_open(server_rec *s, pool *p) { -#ifndef WIN32 SSLModConfigRec *mc = myModConfig(); /* open the lockfile (once per child) to get a unique fd */ @@ -185,32 +182,26 @@ void ssl_mutex_file_open(server_rec *s, pool *p) mc->szMutexFile); ssl_die(); } -#endif return; } void ssl_mutex_file_remove(void *data) { -#ifndef WIN32 SSLModConfigRec *mc = myModConfig(); /* remove the mutex lockfile */ unlink(mc->szMutexFile); -#endif return; } -#ifndef WIN32 #ifdef SSL_USE_FCNTL static struct flock lock_it; static struct flock unlock_it; #endif -#endif BOOL ssl_mutex_file_acquire(void) { int rc = -1; -#ifndef WIN32 SSLModConfigRec *mc = myModConfig(); #ifdef SSL_USE_FCNTL @@ -228,7 +219,6 @@ BOOL ssl_mutex_file_acquire(void) while ( ((rc = flock(mc->nMutexFD, LOCK_EX)) < 0) && (errno == EINTR) ) ; -#endif #endif if (rc < 0) @@ -240,7 +230,6 @@ BOOL ssl_mutex_file_acquire(void) BOOL ssl_mutex_file_release(void) { int rc = -1; -#ifndef WIN32 SSLModConfigRec *mc = myModConfig(); #ifdef SSL_USE_FCNTL @@ -258,7 +247,6 @@ BOOL ssl_mutex_file_release(void) while ( (rc = flock(mc->nMutexFD, LOCK_UN)) < 0 && (errno == EINTR) ) ; -#endif #endif if (rc < 0) diff --git a/modules/ssl/ssl_util.c b/modules/ssl/ssl_util.c index c8ff17e967..3b23075cf9 100644 --- a/modules/ssl/ssl_util.c +++ b/modules/ssl/ssl_util.c @@ -168,39 +168,7 @@ int ssl_util_ppopen_child(void *cmd, child_info *pinfo) /* * Exec() the child program */ -#if defined(WIN32) - /* MS Windows */ - { - char pCommand[MAX_STRING_LEN]; - STARTUPINFO si; - PROCESS_INFORMATION pi; - - ap_snprintf(pCommand, sizeof(pCommand), "%s /C %s", SHELL_PATH, cmd); - - memset(&si, 0, sizeof(si)); - memset(&pi, 0, sizeof(pi)); - - si.cb = sizeof(si); - si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES; - si.wShowWindow = SW_HIDE; - si.hStdInput = pinfo->hPipeInputRead; - si.hStdOutput = pinfo->hPipeOutputWrite; - si.hStdError = pinfo->hPipeErrorWrite; - - if (CreateProcess(NULL, pCommand, NULL, NULL, TRUE, 0, - environ, NULL, &si, &pi)) { - CloseHandle(pi.hProcess); - CloseHandle(pi.hThread); - child_pid = pi.dwProcessId; - } - } -#elif defined(OS2) - /* IBM OS/2 */ - spawnl(P_NOWAIT, SHELL_PATH, SHELL_PATH, "/c", (char *)cmd, NULL); -#else - /* Standard Unix */ execl(SHELL_PATH, SHELL_PATH, "-c", (char *)cmd, NULL); -#endif return (child_pid); }