]> granicus.if.org Git - apache/commitdiff
Forgot listen.c in the earlier AcceptEx patch to winnt.c.
authorBill Stoddard <stoddard@apache.org>
Sat, 21 Aug 1999 04:43:15 +0000 (04:43 +0000)
committerBill Stoddard <stoddard@apache.org>
Sat, 21 Aug 1999 04:43:15 +0000 (04:43 +0000)
Enable winnt mpm to detech OS at runtime.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@83743 13f79535-47bb-0310-9956-ffa450edef68

server/listen.c
server/mpm/winnt/mpm_winnt.c

index 14624d6dac38eb8045b0400891e0a920b7d8496e..5e73cc50900b6af3c4e96dcca850bb0d74d57d31 100644 (file)
@@ -78,11 +78,20 @@ static int make_sock(const struct sockaddr_in *server)
     else
        ap_snprintf(addr, sizeof(addr), "port %d", ntohs(server->sin_port));
 
+#ifdef WIN32
+    s = WSASocket(AF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, 0, WSA_FLAG_OVERLAPPED);
+    if (s == INVALID_SOCKET) {
+       ap_log_error(APLOG_MARK, APLOG_CRIT, NULL,
+                     "make_sock: failed to get a socket for %s", addr);
+       return -1;
+    }
+#else
     if ((s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) {
        ap_log_error(APLOG_MARK, APLOG_CRIT, NULL,
                    "make_sock: failed to get a socket for %s", addr);
        return -1;
     }
+#endif
 
 #ifdef SO_REUSEADDR
     if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *) &one, sizeof(int)) < 0) {
index 299675062b7274fc01f1e2fee4c95887ebf7dbcf..1adf15002d16563fb5dabcba31958193b9b05d57 100644 (file)
@@ -94,6 +94,8 @@ static char ap_coredump_dir[MAX_STRING_LEN];
 static server_rec *server_conf;
 
 static int one_process = 0;
+
+static OSVERSIONINFO osver; /* VER_PLATFORM_WIN32_NT */
 event *exit_event;
 mutex *start_mutex;
 int my_pid;
@@ -767,12 +769,12 @@ static void child_main(int child_num)
        ap_clear_pool(lpCompContext->ptrans);
         lpCompContext->conn_io =  ap_bcreate(lpCompContext->ptrans, B_RDWR);
 
+        /* Grab a connection off the network */
+        if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT)
+            lpCompContext = winnt_get_connection(lpCompContext);
+        else
+            lpCompContext = win9x_get_connection(lpCompContext);
 
-#ifdef QUEUED_ACCEPT
-        lpCompContext = win9x_get_connection(lpCompContext);
-#else
-        lpCompContext = winnt_get_connection(lpCompContext);
-#endif
 
         if (!lpCompContext)
             break;
@@ -954,10 +956,9 @@ static void worker_main()
        child_handles[i] = create_thread((void (*)(void *)) child_main, (void *) i);
     }
 
-#ifdef QUEUED_ACCEPT
-    /* spawn off accept thread */
-    create_thread((void (*)(void *)) accept_and_queue_connections, (void *) NULL);
-#endif
+    /* spawn off accept thread (WIN9x only) */
+    if (osver.dwPlatformId != VER_PLATFORM_WIN32_NT)
+        create_thread((void (*)(void *)) accept_and_queue_connections, (void *) NULL);
 
     rv = WaitForSingleObject(exit_event, INFINITE);
     printf("exit event signalled \n");
@@ -965,11 +966,17 @@ static void worker_main()
 
     /* Get ready to shutdown and exit */
     ap_release_mutex(start_mutex);
-#ifdef QUEUED_ACCEPT
-    for (i = 0; i < nthreads; i++) {
-       add_job(-1);
+
+    if (osver.dwPlatformId != VER_PLATFORM_WIN32_NT) {
+        /* This is only needed for platforms that use the accept queue code 
+         * (WIN9x only). It should work on NT but not as efficiently as the 
+         * code written specifically for Windows NT.
+         */
+        for (i = 0; i < nthreads; i++) {
+            add_job(-1);
+        }
     }
-#endif
+
     /* Wait for all your children */
     end_time = time(NULL) + 180;
     while (nthreads) {
@@ -1360,6 +1367,9 @@ static void winnt_pre_config(pool *pconf, pool *plog, pool *ptemp)
     char *pid;
     one_process=1;//!!getenv("ONE_PROCESS");
 
+    osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+    GetVersionEx(&osver);
+
     /* AP_PARENT_PID is only valid in the child */
     pid = getenv("AP_PARENT_PID");
     if (pid) {