You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by wr...@apache.org on 2009/01/02 20:24:09 UTC

svn commit: r730828 - in /httpd/httpd/trunk/server/mpm/winnt: Win9xConHook.c Win9xConHook.def Win9xConHook.dsp Win9xConHook.h child.c mpm_winnt.c mpm_winnt.h service.c

Author: wrowe
Date: Fri Jan  2 11:24:08 2009
New Revision: 730828

URL: http://svn.apache.org/viewvc?rev=730828&view=rev
Log:
Axe Win9x codepath, including Win32DisableAcceptEx logic.  Starting clean.

Removed:
    httpd/httpd/trunk/server/mpm/winnt/Win9xConHook.c
    httpd/httpd/trunk/server/mpm/winnt/Win9xConHook.def
    httpd/httpd/trunk/server/mpm/winnt/Win9xConHook.dsp
    httpd/httpd/trunk/server/mpm/winnt/Win9xConHook.h
Modified:
    httpd/httpd/trunk/server/mpm/winnt/child.c
    httpd/httpd/trunk/server/mpm/winnt/mpm_winnt.c
    httpd/httpd/trunk/server/mpm/winnt/mpm_winnt.h
    httpd/httpd/trunk/server/mpm/winnt/service.c

Modified: httpd/httpd/trunk/server/mpm/winnt/child.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/winnt/child.c?rev=730828&r1=730827&r2=730828&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/winnt/child.c (original)
+++ httpd/httpd/trunk/server/mpm/winnt/child.c Fri Jan  2 11:24:08 2009
@@ -244,246 +244,6 @@
 }
 
 
-/* Windows 9x specific code...
- * Accept processing for on Windows 95/98 uses a producer/consumer queue
- * model. A single thread accepts connections and queues the accepted socket
- * to the accept queue for consumption by a pool of worker threads.
- *
- * win9x_accept()
- *    The accept threads runs this function, which accepts connections off
- *    the network and calls add_job() to queue jobs to the accept_queue.
- * add_job()/remove_job()
- *    Add or remove an accepted socket from the list of sockets
- *    connected to clients. allowed_globals.jobmutex protects
- *    against multiple concurrent access to the linked list of jobs.
- * win9x_get_connection()
- *    Calls remove_job() to pull a job from the accept queue. All the worker
- *    threads block on remove_job.
- */
-
-typedef struct joblist_s {
-    struct joblist_s *next;
-    SOCKET sock;
-} joblist;
-
-typedef struct globals_s {
-    HANDLE jobsemaphore;
-    joblist *jobhead;
-    joblist *jobtail;
-    apr_thread_mutex_t *jobmutex;
-    int jobcount;
-} globals;
-
-globals allowed_globals = {NULL, NULL, NULL, NULL, 0};
-
-#define MAX_SELECT_ERRORS 100
-
-
-static void add_job(SOCKET sock)
-{
-    joblist *new_job;
-
-    new_job = (joblist *) malloc(sizeof(joblist));
-    if (new_job == NULL) {
-        ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
-                     "Ouch!  Out of memory in add_job()!");
-        return;
-    }
-    new_job->next = NULL;
-    new_job->sock = sock;
-
-    apr_thread_mutex_lock(allowed_globals.jobmutex);
-
-    if (allowed_globals.jobtail != NULL)
-        allowed_globals.jobtail->next = new_job;
-    allowed_globals.jobtail = new_job;
-    if (!allowed_globals.jobhead)
-        allowed_globals.jobhead = new_job;
-    allowed_globals.jobcount++;
-    ReleaseSemaphore(allowed_globals.jobsemaphore, 1, NULL);
-
-    apr_thread_mutex_unlock(allowed_globals.jobmutex);
-}
-
-
-static SOCKET remove_job(void)
-{
-    joblist *job;
-    SOCKET sock;
-
-    WaitForSingleObject(allowed_globals.jobsemaphore, INFINITE);
-    apr_thread_mutex_lock(allowed_globals.jobmutex);
-
-    if (shutdown_in_progress && !allowed_globals.jobhead) {
-        apr_thread_mutex_unlock(allowed_globals.jobmutex);
-        return (INVALID_SOCKET);
-    }
-    job = allowed_globals.jobhead;
-    ap_assert(job);
-    allowed_globals.jobhead = job->next;
-    if (allowed_globals.jobhead == NULL)
-        allowed_globals.jobtail = NULL;
-    apr_thread_mutex_unlock(allowed_globals.jobmutex);
-    sock = job->sock;
-    free(job);
-
-    return (sock);
-}
-
-
-static unsigned int __stdcall win9x_accept(void * dummy)
-{
-    struct timeval tv;
-    fd_set main_fds;
-    int wait_time = 1;
-    SOCKET csd;
-    SOCKET nsd = INVALID_SOCKET;
-    int count_select_errors = 0;
-    int rc;
-    int clen;
-    ap_listen_rec *lr;
-    struct fd_set listenfds;
-#if APR_HAVE_IPV6
-    struct sockaddr_in6 sa_client;
-#else
-    struct sockaddr_in sa_client;
-#endif
-
-    /* Setup the listeners
-     * ToDo: Use apr_poll()
-     */
-    FD_ZERO(&listenfds);
-    for (lr = ap_listeners; lr; lr = lr->next) {
-        if (lr->sd != NULL) {
-            apr_os_sock_get(&nsd, lr->sd);
-            FD_SET(nsd, &listenfds);
-            ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf,
-                         "Child %d: Listening on port %d.", my_pid, 
-                         lr->bind_addr->port);
-        }
-    }
-
-    head_listener = ap_listeners;
-
-    while (!shutdown_in_progress) {
-        tv.tv_sec = wait_time;
-        tv.tv_usec = 0;
-        memcpy(&main_fds, &listenfds, sizeof(fd_set));
-
-        /* First parameter of select() is ignored on Windows */
-        rc = select(0, &main_fds, NULL, NULL, &tv);
-
-        if (rc == 0 || ((rc == SOCKET_ERROR)
-                         && APR_STATUS_IS_EINTR(apr_get_netos_error()))) {
-            count_select_errors = 0;    /* reset count of errors */
-            continue;
-        }
-        else if (rc == SOCKET_ERROR) {
-            /* A "real" error occurred, log it and increment the count of
-             * select errors. This count is used to ensure we don't go into
-             * a busy loop of continuous errors.
-             */
-            ap_log_error(APLOG_MARK, APLOG_INFO, apr_get_netos_error(), 
-                         ap_server_conf,
-                         "select failed with error %d", apr_get_netos_error());
-            count_select_errors++;
-            if (count_select_errors > MAX_SELECT_ERRORS) {
-                shutdown_in_progress = 1;
-                ap_log_error(APLOG_MARK, APLOG_ERR, apr_get_netos_error(), 
-                             ap_server_conf,
-                             "Too many errors in select loop. "
-                             "Child process exiting.");
-                break;
-            }
-        } else {
-            ap_listen_rec *lr;
-
-            lr = find_ready_listener(&main_fds);
-            if (lr != NULL) {
-                /* fetch the native socket descriptor */
-                apr_os_sock_get(&nsd, lr->sd);
-            }
-        }
-
-        do {
-            clen = sizeof(sa_client);
-            csd = accept(nsd, (struct sockaddr *) &sa_client, &clen);
-        } while (csd < 0 && APR_STATUS_IS_EINTR(apr_get_netos_error()));
-
-        if (csd < 0) {
-            if (APR_STATUS_IS_ECONNABORTED(apr_get_netos_error())) {
-                ap_log_error(APLOG_MARK, APLOG_ERR, apr_get_netos_error(), 
-                             ap_server_conf, "accept: (client socket)");
-            }
-        }
-        else {
-            add_job(csd);
-        }
-    }
-    SetEvent(exit_event);
-    return 0;
-}
-
-
-static PCOMP_CONTEXT win9x_get_connection(PCOMP_CONTEXT context)
-{
-    apr_os_sock_info_t sockinfo;
-    int len, salen;
-#if APR_HAVE_IPV6
-    salen = sizeof(struct sockaddr_in6);
-#else
-    salen = sizeof(struct sockaddr_in);
-#endif
-
-
-    if (context == NULL) {
-        /* allocate the completion context and the transaction pool */
-        apr_allocator_t *allocator;
-        apr_thread_mutex_lock(child_lock);
-        context = apr_pcalloc(pchild, sizeof(COMP_CONTEXT));
-        apr_allocator_create(&allocator);
-        apr_allocator_max_free_set(allocator, ap_max_mem_free);
-        apr_pool_create_ex(&context->ptrans, pchild, NULL, allocator);
-        apr_allocator_owner_set(allocator, context->ptrans);
-        apr_pool_tag(context->ptrans, "transaction");
-        apr_thread_mutex_unlock(child_lock);
-    }
-
-    while (1) {
-        apr_pool_clear(context->ptrans);
-        context->ba = apr_bucket_alloc_create(context->ptrans);
-        context->accept_socket = remove_job();
-        if (context->accept_socket == INVALID_SOCKET) {
-            return NULL;
-        }
-        len = salen;
-        context->sa_server = apr_palloc(context->ptrans, len);
-        if (getsockname(context->accept_socket,
-                        context->sa_server, &len)== SOCKET_ERROR) {
-            ap_log_error(APLOG_MARK, APLOG_WARNING, apr_get_netos_error(), 
-                         ap_server_conf, "getsockname failed");
-            continue;
-        }
-        len = salen;
-        context->sa_client = apr_palloc(context->ptrans, len);
-        if ((getpeername(context->accept_socket,
-                         context->sa_client, &len)) == SOCKET_ERROR) {
-            ap_log_error(APLOG_MARK, APLOG_WARNING, apr_get_netos_error(), 
-                         ap_server_conf, "getpeername failed");
-            memset(&context->sa_client, '\0', sizeof(context->sa_client));
-        }
-        sockinfo.os_sock = &context->accept_socket;
-        sockinfo.local   = context->sa_server;
-        sockinfo.remote  = context->sa_client;
-        sockinfo.family  = context->sa_server->sa_family;
-        sockinfo.type    = SOCK_STREAM;
-        apr_os_sock_make(&context->sock, &sockinfo, context->ptrans);
-
-        return context;
-    }
-}
-
-
 /* Windows NT/2000 specific code...
  * Accept processing for on Windows NT uses a producer/consumer queue
  * model. An accept thread accepts connections off the network then issues
@@ -603,7 +363,7 @@
                                  "faults accepting client connections. "
                                  "Possible causes: dynamic address renewal, "
                                  "or incompatible VPN or firewall software. "
-                                 "Try the directive Win32DisableAcceptEx.",
+                                 "Try the directive 'AcceptFilter none'.",
                                  my_pid);
                     err_count = 0;
                 }
@@ -617,7 +377,7 @@
                                  "Child %d: Encountered too many AcceptEx "
                                  "faults accepting client connections. "
                                  "Possible causes: Unknown. "
-                                 "Try the directive Win32DisableAcceptEx.",
+                                 "Try the directive 'AcceptFilter none'.",
                                  my_pid);
                     err_count = 0;
                 }
@@ -776,12 +536,7 @@
         ap_update_child_status_from_indexes(0, thread_num, SERVER_READY, NULL);
 
         /* Grab a connection off the network */
-        if (use_acceptex) {
-            context = winnt_get_connection(context);
-        }
-        else {
-            context = win9x_get_connection(context);
-        }
+        context = winnt_get_connection(context);
 
         if (!context) {
             /* Time for the thread to exit */
@@ -809,15 +564,17 @@
                 context->accept_socket = INVALID_SOCKET;
                 ap_lingering_close(c);
             }
-            else if (!use_acceptex) {
+            else {
                 /* If the socket is disconnected but we are not using acceptex,
                  * we cannot reuse the socket. Disconnected sockets are removed
                  * from the apr_socket_t struct by apr_sendfile() to prevent the
                  * socket descriptor from being inadvertently closed by a call
                  * to apr_socket_close(), so close it directly.
                  */
-                closesocket(context->accept_socket);
-                context->accept_socket = INVALID_SOCKET;
+                /* XXX Study me for NT;
+                 * closesocket(context->accept_socket);
+                 * context->accept_socket = INVALID_SOCKET;
+                 */
             }
         }
         else {
@@ -856,41 +613,32 @@
 {
     int tid;
     int num_listeners = 0;
-    if (!use_acceptex) {
-        /* A smaller stack is sufficient.
-         * To convert to CreateThread, the returned handle cannot be 
-         * ignored, it must be closed/joined.
-         */
-        _beginthreadex(NULL, 65536, win9x_accept,
-                       NULL, stack_res_flag, &tid);
-    } else {
-        /* Start an accept thread per listener
-         * XXX: Why would we have a NULL sd in our listeners?
-         */
-        ap_listen_rec *lr;
+    /* Start an accept thread per listener
+     * XXX: Why would we have a NULL sd in our listeners?
+     */
+    ap_listen_rec *lr;
 
-        /* Number of completion_contexts allowed in the system is
-         * (ap_threads_per_child + num_listeners). We need the additional
-         * completion contexts to prevent server hangs when ThreadsPerChild
-         * is configured to something less than or equal to the number
-         * of listeners. This is not a usual case, but people have
-         * encountered it.
-         * */
-        for (lr = ap_listeners; lr ; lr = lr->next) {
-            num_listeners++;
-        }
-        max_num_completion_contexts = ap_threads_per_child + num_listeners;
-
-        /* Now start a thread per listener */
-        for (lr = ap_listeners; lr; lr = lr->next) {
-            if (lr->sd != NULL) {
-                /* A smaller stack is sufficient.
-                 * To convert to CreateThread, the returned handle cannot be 
-                 * ignored, it must be closed/joined.
-                 */
-                _beginthreadex(NULL, 65536, winnt_accept,
-                               (void *) lr, stack_res_flag, &tid);
-            }
+    /* Number of completion_contexts allowed in the system is
+     * (ap_threads_per_child + num_listeners). We need the additional
+     * completion contexts to prevent server hangs when ThreadsPerChild
+     * is configured to something less than or equal to the number
+     * of listeners. This is not a usual case, but people have
+     * encountered it.
+     */
+    for (lr = ap_listeners; lr ; lr = lr->next) {
+        num_listeners++;
+    }
+    max_num_completion_contexts = ap_threads_per_child + num_listeners;
+
+    /* Now start a thread per listener */
+    for (lr = ap_listeners; lr; lr = lr->next) {
+        if (lr->sd != NULL) {
+            /* A smaller stack is sufficient.
+             * To convert to CreateThread, the returned handle cannot be 
+             * ignored, it must be closed/joined.
+             */
+            _beginthreadex(NULL, 65536, winnt_accept,
+                           (void *) lr, stack_res_flag, &tid);
         }
     }
 }
@@ -929,10 +677,6 @@
     child_events[0] = exit_event;
     child_events[1] = max_requests_per_child_event;
 
-    allowed_globals.jobsemaphore = CreateSemaphore(NULL, 0, 1000000, NULL);
-    apr_thread_mutex_create(&allowed_globals.jobmutex,
-                            APR_THREAD_MUTEX_DEFAULT, pchild);
-
     /*
      * Wait until we have permission to start accepting connections.
      * start_mutex is used to ensure that only one child ever
@@ -950,20 +694,17 @@
 
     /*
      * Create the worker thread dispatch IOCompletionPort
-     * on Windows NT/2000
      */
-    if (use_acceptex) {
-        /* Create the worker thread dispatch IOCP */
-        ThreadDispatchIOCP = CreateIoCompletionPort(INVALID_HANDLE_VALUE,
-                                                    NULL, 0, 0); 
-        apr_thread_mutex_create(&qlock, APR_THREAD_MUTEX_DEFAULT, pchild);
-        qwait_event = CreateEvent(NULL, TRUE, FALSE, NULL);
-        if (!qwait_event) {
-            ap_log_error(APLOG_MARK, APLOG_CRIT, apr_get_os_error(), 
-                         ap_server_conf,
-                         "Child %d: Failed to create a qwait event.", my_pid);
-            exit(APEXIT_CHILDINIT);
-        }
+    /* Create the worker thread dispatch IOCP */
+    ThreadDispatchIOCP = CreateIoCompletionPort(INVALID_HANDLE_VALUE,
+                                                NULL, 0, 0); 
+    apr_thread_mutex_create(&qlock, APR_THREAD_MUTEX_DEFAULT, pchild);
+    qwait_event = CreateEvent(NULL, TRUE, FALSE, NULL);
+    if (!qwait_event) {
+        ap_log_error(APLOG_MARK, APLOG_CRIT, apr_get_os_error(), 
+                     ap_server_conf,
+                     "Child %d: Failed to create a qwait event.", my_pid);
+        exit(APEXIT_CHILDINIT);
     }
 
     /*
@@ -1131,34 +872,27 @@
                      "Child %d: Failure releasing the start mutex", my_pid);
     }
 
-    /* Shutdown the worker threads */
-    if (!use_acceptex) {
-        for (i = 0; i < threads_created; i++) {
-            add_job(INVALID_SOCKET);
-        }
-    }
-    else { /* Windows NT/2000 */
-        /* Post worker threads blocked on the ThreadDispatch IOCompletion port
-         */
-        while (g_blocked_threads > 0) {
-            ap_log_error(APLOG_MARK, APLOG_INFO, APR_SUCCESS, ap_server_conf,
-                         "Child %d: %d threads blocked on the completion port",
-                         my_pid, g_blocked_threads);
-            for (i=g_blocked_threads; i > 0; i--) {
-                PostQueuedCompletionStatus(ThreadDispatchIOCP, 0, 
-                                           IOCP_SHUTDOWN, NULL);
-            }
-            Sleep(1000);
-        }
-        /* Empty the accept queue of completion contexts */
-        apr_thread_mutex_lock(qlock);
-        while (qhead) {
-            CloseHandle(qhead->Overlapped.hEvent);
-            closesocket(qhead->accept_socket);
-            qhead = qhead->next;
-        }
-        apr_thread_mutex_unlock(qlock);
+    /* Shutdown the worker threads
+     * Post worker threads blocked on the ThreadDispatch IOCompletion port
+     */
+    while (g_blocked_threads > 0) {
+        ap_log_error(APLOG_MARK, APLOG_INFO, APR_SUCCESS, ap_server_conf,
+                     "Child %d: %d threads blocked on the completion port",
+                     my_pid, g_blocked_threads);
+        for (i=g_blocked_threads; i > 0; i--) {
+            PostQueuedCompletionStatus(ThreadDispatchIOCP, 0, 
+                                       IOCP_SHUTDOWN, NULL);
+        }
+        Sleep(1000);
+    }
+    /* Empty the accept queue of completion contexts */
+    apr_thread_mutex_lock(qlock);
+    while (qhead) {
+        CloseHandle(qhead->Overlapped.hEvent);
+        closesocket(qhead->accept_socket);
+        qhead = qhead->next;
     }
+    apr_thread_mutex_unlock(qlock);
 
     /* Give busy threads a chance to service their connections,
      * (no more than the global server timeout period which 
@@ -1244,15 +978,8 @@
     ap_log_error(APLOG_MARK, APLOG_NOTICE, APR_SUCCESS, ap_server_conf,
                  "Child %d: All worker threads have exited.", my_pid);
 
-    CloseHandle(allowed_globals.jobsemaphore);
-    apr_thread_mutex_destroy(allowed_globals.jobmutex);
     apr_thread_mutex_destroy(child_lock);
 
-    if (use_acceptex) {
-        apr_thread_mutex_destroy(qlock);
-        CloseHandle(qwait_event);
-    }
-
     apr_pool_destroy(pchild);
     CloseHandle(exit_event);
 }

Modified: httpd/httpd/trunk/server/mpm/winnt/mpm_winnt.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/winnt/mpm_winnt.c?rev=730828&r1=730827&r2=730828&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/winnt/mpm_winnt.c (original)
+++ httpd/httpd/trunk/server/mpm/winnt/mpm_winnt.c Fri Jan  2 11:24:08 2009
@@ -63,7 +63,6 @@
 DWORD my_pid;
 
 int ap_threads_per_child = 0;
-int use_acceptex = 1;
 static int thread_limit = 0;
 static int first_thread_limit = 0;
 int winnt_mpm_state = AP_MPMQ_STARTING;
@@ -137,19 +136,6 @@
     thread_limit = atoi(arg);
     return NULL;
 }
-static const char *set_disable_acceptex(cmd_parms *cmd, void *dummy, char *arg)
-{
-    const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
-    if (err != NULL) {
-        return err;
-    }
-    if (use_acceptex) {
-        use_acceptex = 0;
-        ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, NULL,
-                     "Disabled use of AcceptEx() WinSock2 API");
-    }
-    return NULL;
-}
 
 static const command_rec winnt_cmds[] = {
 LISTEN_COMMANDS,
@@ -157,9 +143,6 @@
   "Number of threads each child creates" ),
 AP_INIT_TAKE1("ThreadLimit", set_thread_limit, NULL, RSRC_CONF,
   "Maximum worker threads in a server for this run of Apache"),
-AP_INIT_NO_ARGS("Win32DisableAcceptEx", set_disable_acceptex, NULL, RSRC_CONF,
-  "Disable use of the high performance AcceptEx WinSock2 API to work around buggy VPN or Firewall software"),
-
 { NULL }
 };
 
@@ -449,6 +432,8 @@
     DWORD BytesRead;
     int lcnt = 0;
     SOCKET nsd;
+    HANDLE hProcess = GetCurrentProcess();
+    HANDLE dup;
 
     /* Set up a default listener if necessary */
     if (ap_listeners == NULL) {
@@ -472,6 +457,7 @@
                          "setup_inherited_listeners: Unable to read socket data from parent");
             exit(APEXIT_CHILDINIT);
         }
+
         nsd = WSASocket(FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO,
                         &WSAProtocolInfo, 0, 0);
         if (nsd == INVALID_SOCKET) {
@@ -480,30 +466,12 @@
             exit(APEXIT_CHILDINIT);
         }
 
-        if (osver.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
-            HANDLE hProcess = GetCurrentProcess();
-            HANDLE dup;
-            if (DuplicateHandle(hProcess, (HANDLE) nsd, hProcess, &dup,
-                                0, FALSE, DUPLICATE_SAME_ACCESS)) {
-                closesocket(nsd);
-                nsd = (SOCKET) dup;
-            }
-        }
-        else {
-            /* A different approach.  Many users report errors such as
-             * (32538)An operation was attempted on something that is not
-             * a socket.  : Parent: WSADuplicateSocket failed...
-             *
-             * This appears that the duplicated handle is no longer recognized
-             * as a socket handle.  SetHandleInformation should overcome that
-             * problem by not altering the handle identifier.  But this won't
-             * work on 9x - it's unsupported.
-             */
-            if (!SetHandleInformation((HANDLE)nsd, HANDLE_FLAG_INHERIT, 0)) {
-                ap_log_error(APLOG_MARK, APLOG_ERR, apr_get_os_error(), ap_server_conf,
-                             "set_listeners_noninheritable: SetHandleInformation failed.");
-            }
+        if (DuplicateHandle(hProcess, (HANDLE) nsd, hProcess, &dup,
+                            0, FALSE, DUPLICATE_SAME_ACCESS)) {
+            closesocket(nsd);
+            nsd = (SOCKET) dup;
         }
+
         apr_os_sock_put(&lr->sd, &nsd, s->process->pool);
     }
 
@@ -991,7 +959,7 @@
 {
     /* Handle the following SCM aspects in this phase:
      *
-     *   -k runservice [transition for WinNT, nothing for Win9x]
+     *   -k runservice [transition in service context only]
      *   -k install
      *   -k config
      *   -k uninstall
@@ -1014,6 +982,7 @@
     apr_getopt_t *opt;
     int running_as_service = 1;
     int errout = 0;
+    apr_file_t *nullfile;
 
     pconf = process->pconf;
 
@@ -1214,33 +1183,28 @@
          * We hold the return value so that we can die in pre_config
          * after logging begins, and the failure can land in the log.
          */
-        if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT)
-        {
-            apr_file_t *nullfile;
-
-            if (!errout) {
-                mpm_nt_eventlog_stderr_open(service_name, process->pool);
-            }
-            service_to_start_success = mpm_service_to_start(&service_name,
-                                                            process->pool);
-            if (service_to_start_success == APR_SUCCESS) {
-                service_set = APR_SUCCESS;
-            }
+        if (!errout) {
+            mpm_nt_eventlog_stderr_open(service_name, process->pool);
+        }
+        service_to_start_success = mpm_service_to_start(&service_name,
+                                                        process->pool);
+        if (service_to_start_success == APR_SUCCESS) {
+            service_set = APR_SUCCESS;
+        }
 
-            /* Open a null handle to soak stdout in this process.
-             * Windows service processes are missing any file handle
-             * usable for stdin/out/err.  This was the cause of later 
-             * trouble with invocations of apr_file_open_stdout()
-             */
-            if ((rv = apr_file_open(&nullfile, "NUL",
-                                    APR_READ | APR_WRITE, APR_OS_DEFAULT,
-                                    process->pool)) == APR_SUCCESS) {
-                apr_file_t *nullstdout;
-                if (apr_file_open_stdout(&nullstdout, process->pool)
-                        == APR_SUCCESS)
-                    apr_file_dup2(nullstdout, nullfile, process->pool);
-                apr_file_close(nullfile);
-            }
+        /* Open a null handle to soak stdout in this process.
+         * Windows service processes are missing any file handle
+         * usable for stdin/out/err.  This was the cause of later 
+         * trouble with invocations of apr_file_open_stdout()
+         */
+        if ((rv = apr_file_open(&nullfile, "NUL",
+                                APR_READ | APR_WRITE, APR_OS_DEFAULT,
+                                process->pool)) == APR_SUCCESS) {
+            apr_file_t *nullstdout;
+            if (apr_file_open_stdout(&nullstdout, process->pool)
+                    == APR_SUCCESS)
+                apr_file_dup2(nullstdout, nullfile, process->pool);
+            apr_file_close(nullfile);
         }
     }
 
@@ -1387,20 +1351,12 @@
         }
     }
 
-    /* use_acceptex (enabled by default) is not available on Win9x.
-     */
-    if (osver.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
-        use_acceptex = 0;
-    }
-
     ap_listen_pre_config();
     thread_limit = DEFAULT_THREAD_LIMIT;
     ap_threads_per_child = DEFAULT_THREADS_PER_CHILD;
     ap_pid_fname = DEFAULT_PIDLOG;
     ap_max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD;
-#ifdef AP_MPM_WANT_SET_MAX_MEM_FREE
-        ap_max_mem_free = APR_ALLOCATOR_MAX_FREE_UNLIMITED;
-#endif
+    ap_max_mem_free = APR_ALLOCATOR_MAX_FREE_UNLIMITED;
 
     apr_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir));
 

Modified: httpd/httpd/trunk/server/mpm/winnt/mpm_winnt.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/winnt/mpm_winnt.h?rev=730828&r1=730827&r2=730828&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/winnt/mpm_winnt.h (original)
+++ httpd/httpd/trunk/server/mpm/winnt/mpm_winnt.h Fri Jan  2 11:24:08 2009
@@ -35,7 +35,6 @@
 #define AP_DEFAULT_SERVICE_NAME "Apache2.x"
 #endif
 
-#define SERVICECONFIG9X "Software\\Microsoft\\Windows\\CurrentVersion\\RunServices"
 #define SERVICECONFIG "System\\CurrentControlSet\\Services\\%s"
 #define SERVICEPARAMS "System\\CurrentControlSet\\Services\\%s\\Parameters"
 
@@ -67,7 +66,6 @@
 
 /* From mpm_winnt.c: */
 
-extern int use_acceptex;
 extern int winnt_mpm_state;
 extern OSVERSIONINFO osver;
 extern DWORD stack_res_flag;

Modified: httpd/httpd/trunk/server/mpm/winnt/service.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/winnt/service.c?rev=730828&r1=730827&r2=730828&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/winnt/service.c (original)
+++ httpd/httpd/trunk/server/mpm/winnt/service.c Fri Jan  2 11:24:08 2009
@@ -94,10 +94,6 @@
  *     \DisplayName
  *     \ImagePath
  *     \Parameters\ConfigArgs
- *
- * For Win9x, the launch service command is stored under:
- *
- * HKLM\Software\Microsoft\Windows\CurrentVersion\RunServices\[service name]
  */
 
 
@@ -168,101 +164,6 @@
 
 static BOOL  die_on_logoff = FALSE;
 
-static LRESULT CALLBACK monitor_service_9x_proc(HWND hWnd, UINT msg,
-                                                WPARAM wParam, LPARAM lParam)
-{
-/* This is the WndProc procedure for our invisible window.
- * When the user shuts down the system, this window is sent
- * a signal WM_ENDSESSION. We clean up by signaling Apache
- * to shut down, and idle until Apache's primary thread quits.
- */
-    if ((msg == WM_ENDSESSION)
-            && (die_on_logoff || (lParam != ENDSESSION_LOGOFF)))
-    {
-        ap_signal_parent(SIGNAL_PARENT_SHUTDOWN);
-        if (wParam)
-            /* Don't leave this message until we are dead! */
-            WaitForSingleObject(globdat.mpm_thread, 30000);
-        return 0;
-    }
-    return (DefWindowProc(hWnd, msg, wParam, lParam));
-}
-
-static DWORD WINAPI monitor_service_9x_thread(void *service_name)
-{
-    /* When running as a service under Windows 9x, there is no console
-     * window present, and no ConsoleCtrlHandler to call when the system
-     * is shutdown.  If the WatchWindow thread is created with a NULL
-     * service_name argument, then the ...SystemMonitor window class is
-     * used to create the "Apache" window to watch for logoff and shutdown.
-     * If the service_name is provided, the ...ServiceMonitor window class
-     * is used to create the window named by the service_name argument,
-     * and the logoff message is ignored.
-     */
-    WNDCLASS wc;
-    HWND hwndMain;
-    MSG msg;
-
-    wc.style         = CS_GLOBALCLASS;
-    wc.lpfnWndProc   = monitor_service_9x_proc;
-    wc.cbClsExtra    = 0;
-    wc.cbWndExtra    = 0;
-    wc.hInstance     = NULL;
-    wc.hIcon         = NULL;
-    wc.hCursor       = NULL;
-    wc.hbrBackground = NULL;
-    wc.lpszMenuName  = NULL;
-    if (service_name)
-        wc.lpszClassName = "ApacheWin95ServiceMonitor";
-    else
-        wc.lpszClassName = "ApacheWin95SystemMonitor";
-
-    die_on_logoff = service_name ? FALSE : TRUE;
-
-    if (!RegisterClass(&wc))
-    {
-        ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, apr_get_os_error(),
-                     NULL, "Could not register window class for WatchWindow");
-        globdat.service_thread_id = 0;
-        return 0;
-    }
-
-    /* Create an invisible window */
-    hwndMain = CreateWindow(wc.lpszClassName,
-                            service_name ? (char *) service_name : "Apache",
-                            WS_OVERLAPPEDWINDOW & ~WS_VISIBLE,
-                            CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
-                            CW_USEDEFAULT, NULL, NULL, NULL, NULL);
-
-    if (!hwndMain)
-    {
-        ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, apr_get_os_error(),
-                     NULL, "Could not create WatchWindow");
-        globdat.service_thread_id = 0;
-        return 0;
-    }
-
-    /* If we succeed, eliminate the console window.
-     * Signal the parent we are all set up, and
-     * watch the message queue while the window lives.
-     */
-    FreeConsole();
-    SetEvent(globdat.service_init);
-
-    while (GetMessage(&msg, NULL, 0, 0))
-    {
-        if (msg.message == WM_CLOSE)
-            DestroyWindow(hwndMain);
-        else {
-            TranslateMessage(&msg);
-            DispatchMessage(&msg);
-        }
-    }
-    globdat.service_thread_id = 0;
-    return 0;
-}
-
-
 static BOOL CALLBACK console_control_handler(DWORD ctrl_type)
 {
     switch (ctrl_type)
@@ -287,7 +188,6 @@
              * Wait for Apache to terminate, but respond
              * after a reasonable time to tell the system
              * that we did attempt to shut ourself down.
-             * THESE EVENTS WILL NOT OCCUR UNDER WIN9x!
              */
             fprintf(stderr, "Apache server shutdown initiated...\n");
             ap_signal_parent(SIGNAL_PARENT_SHUTDOWN);
@@ -346,22 +246,9 @@
 }
 
 
-static void stop_child_console_handler(void)
-{
-    SetConsoleCtrlHandler(child_control_handler, FALSE);
-}
-
-
 void mpm_start_child_console_handler(void)
 {
-    if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT) {
-        FreeConsole();
-    }
-    else
-    {
-        SetConsoleCtrlHandler(child_control_handler, TRUE);
-        atexit(stop_child_console_handler);
-    }
+    FreeConsole();
 }
 
 
@@ -409,10 +296,12 @@
 }
 
 /* Set the service description regardless of platform.
- * We revert to set_service_description on NT/9x, the
- * very long way so any Apache management program can grab the
- * description.  This would be bad on Win2000, since it wouldn't
- * notify the service control manager of the name change.
+ * We revert to set_service_description, the
+ explicit
+ * way so any Apache management program can grab the
+ * description.  This would be bad on Win2000, since 
+ * it doesn't notify the service control manager of 
+ * the name change.
  */
 
 /* borrowed from mpm_winnt.c */
@@ -420,7 +309,7 @@
 
 /* Windows 2000 alone supports ChangeServiceConfig2 in order to
  * register our server_version string... so we need some fixups
- * to avoid binding to that function if we are on WinNT/9x.
+ * to avoid binding to that function if we are on WinNT.
  */
 static void set_service_description(void)
 {
@@ -679,23 +568,15 @@
     /* Still have a thread & window to clean up, so signal now */
     if (globdat.service_thread)
     {
-        if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT)
-        {
-            /* Stop logging to the event log */
-            mpm_nt_eventlog_stderr_flush();
+        /* Stop logging to the event log */
+        mpm_nt_eventlog_stderr_flush();
 
-            /* Cause the service_nt_main_fn to complete */
-            ReleaseMutex(globdat.service_term);
+        /* Cause the service_nt_main_fn to complete */
+        ReleaseMutex(globdat.service_term);
 
-            ReportStatusToSCMgr(SERVICE_STOPPED, // service state
-                                NO_ERROR,        // exit code
-                                0);              // wait hint
-        }
-        else /* osver.dwPlatformId != VER_PLATFORM_WIN32_NT */
-        {
-            RegisterServiceProcess(0, 0);
-            PostThreadMessage(globdat.service_thread_id, WM_CLOSE, 0, 0);
-        }
+        ReportStatusToSCMgr(SERVICE_STOPPED, // service state
+                            NO_ERROR,        // exit code
+                            0);              // wait hint
 
         WaitForSingleObject(globdat.service_thread, 5000);
         CloseHandle(globdat.service_thread);
@@ -720,34 +601,16 @@
         return APR_ENOTHREAD;
     }
 
-    if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT)
-    {
-        globdat.service_init = CreateEvent(NULL, FALSE, FALSE, NULL);
-        globdat.service_term = CreateMutex(NULL, TRUE, NULL);
-        if (!globdat.service_init || !globdat.service_term) {
-             return APR_EGENERAL;
-        }
-
-        globdat.service_thread = CreateThread(NULL, 65536,
-                                              service_nt_dispatch_thread,
-                                              NULL, stack_res_flag,
-                                              &globdat.service_thread_id);
+    globdat.service_init = CreateEvent(NULL, FALSE, FALSE, NULL);
+    globdat.service_term = CreateMutex(NULL, TRUE, NULL);
+    if (!globdat.service_init || !globdat.service_term) {
+         return APR_EGENERAL;
     }
-    else /* osver.dwPlatformId != VER_PLATFORM_WIN32_NT */
-    {
-        if (!RegisterServiceProcess(0, 1))
-            return GetLastError();
 
-        globdat.service_init = CreateEvent(NULL, FALSE, FALSE, NULL);
-        if (!globdat.service_init) {
-            return APR_EGENERAL;
-        }
-
-        globdat.service_thread = CreateThread(NULL, 0,
-                                              monitor_service_9x_thread,
-                                              (LPVOID) mpm_service_name, 0,
-                                              &globdat.service_thread_id);
-    }
+    globdat.service_thread = CreateThread(NULL, 65536,
+                                          service_nt_dispatch_thread,
+                                          NULL, stack_res_flag,
+                                          &globdat.service_thread_id);
 
     if (!globdat.service_thread) {
         return APR_ENOTHREAD;
@@ -770,22 +633,14 @@
 apr_status_t mpm_service_started(void)
 {
     set_service_description();
-    if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT)
-    {
-        ReportStatusToSCMgr(SERVICE_RUNNING,    // service state
-                            NO_ERROR,           // exit code
-                            0);                 // wait hint
-    }
+    ReportStatusToSCMgr(SERVICE_RUNNING, NO_ERROR, 0);
     return APR_SUCCESS;
 }
 
 
 void mpm_service_stopping(void)
 {
-    if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT)
-        ReportStatusToSCMgr(SERVICE_STOP_PENDING, // service state
-                            NO_ERROR,             // exit code
-                            30000);               // wait hint
+    ReportStatusToSCMgr(SERVICE_STOP_PENDING, NO_ERROR, 30000);
 }
 
 
@@ -797,6 +652,8 @@
     char *launch_cmd;
     ap_regkey_t *key;
     apr_status_t rv;
+    SC_HANDLE   schService;
+    SC_HANDLE   schSCManager;
 
     fprintf(stderr,reconfig ? "Reconfiguring the %s service\n"
                    : "Installing the %s service\n", mpm_display_name);
@@ -810,56 +667,53 @@
         return rv;
     }
 
-    if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT)
-    {
-        SC_HANDLE   schService;
-        SC_HANDLE   schSCManager;
+    schSCManager = OpenSCManager(NULL, NULL, /* local, default database */
+                                 SC_MANAGER_CREATE_SERVICE);
+    if (!schSCManager) {
+        rv = apr_get_os_error();
+        ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL,
+                     "Failed to open the WinNT service manager, perhaps "
+                     "you forgot to log in as Adminstrator?");
+        return (rv);
+    }
 
-        schSCManager = OpenSCManager(NULL, NULL, /* local, default database */
-                                     SC_MANAGER_CREATE_SERVICE);
-        if (!schSCManager) {
-            rv = apr_get_os_error();
-            ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL,
-                         "Failed to open the WinNT service manager");
-            return (rv);
-        }
+    launch_cmd = apr_psprintf(ptemp, "\"%s\" -k runservice", exe_path);
 
-        launch_cmd = apr_psprintf(ptemp, "\"%s\" -k runservice", exe_path);
+    if (reconfig) {
+        /* ###: utf-ize */
+        schService = OpenService(schSCManager, mpm_service_name,
+                                 SERVICE_CHANGE_CONFIG);
+        if (!schService) {
+            ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_ERR,
+                         apr_get_os_error(), NULL,
+                         "OpenService failed");
+        }
+        /* ###: utf-ize */
+        else if (!ChangeServiceConfig(schService,
+                                      SERVICE_WIN32_OWN_PROCESS,
+                                      SERVICE_AUTO_START,
+                                      SERVICE_ERROR_NORMAL,
+                                      launch_cmd, NULL, NULL,
+                                      "Tcpip\0Afd\0", NULL, NULL,
+                                      mpm_display_name)) {
+            ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_ERR,
+                         apr_get_os_error(), NULL,
+                         "ChangeServiceConfig failed");
 
-        if (reconfig) {
-            /* ###: utf-ize */
-            schService = OpenService(schSCManager, mpm_service_name,
-                                     SERVICE_CHANGE_CONFIG);
-            if (!schService) {
-                ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_ERR,
-                             apr_get_os_error(), NULL,
-                             "OpenService failed");
-            }
-            /* ###: utf-ize */
-            else if (!ChangeServiceConfig(schService,
-                                          SERVICE_WIN32_OWN_PROCESS,
-                                          SERVICE_AUTO_START,
-                                          SERVICE_ERROR_NORMAL,
-                                          launch_cmd, NULL, NULL,
-                                          "Tcpip\0Afd\0", NULL, NULL,
-                                          mpm_display_name)) {
-                ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_ERR,
-                             apr_get_os_error(), NULL,
-                             "ChangeServiceConfig failed");
-                /* !schService aborts configuration below */
-                CloseServiceHandle(schService);
-                schService = NULL;
+            /* !schService aborts configuration below */
+            CloseServiceHandle(schService);
+            schService = NULL;
             }
         }
-        else {
-            /* RPCSS is the Remote Procedure Call (RPC) Locator required
-             * for DCOM communication pipes.  I am far from convinced we
-             * should add this to the default service dependencies, but
-             * be warned that future apache modules or ISAPI dll's may
-             * depend on it.
-             */
-            /* ###: utf-ize */
-            schService = CreateService(schSCManager,         // SCManager database
+    else {
+        /* RPCSS is the Remote Procedure Call (RPC) Locator required
+         * for DCOM communication pipes.  I am far from convinced we
+         * should add this to the default service dependencies, but
+         * be warned that future apache modules or ISAPI dll's may
+         * depend on it.
+         */
+        /* ###: utf-ize */
+        schService = CreateService(schSCManager,         // SCManager database
                                    mpm_service_name,     // name of service
                                    mpm_display_name,     // name to display
                                    SERVICE_ALL_ACCESS,   // access required
@@ -873,69 +727,22 @@
                                    NULL,                 // use SYSTEM account
                                    NULL);                // no password
 
-            if (!schService)
-            {
-                rv = apr_get_os_error();
-                ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL,
-                             "Failed to create WinNT Service Profile");
-                CloseServiceHandle(schSCManager);
-                return (rv);
-            }
-        }
-
-        CloseServiceHandle(schService);
-        CloseServiceHandle(schSCManager);
-    }
-    else /* osver.dwPlatformId != VER_PLATFORM_WIN32_NT */
-    {
-        /* Store the launch command in the registry */
-        launch_cmd = apr_psprintf(ptemp, "\"%s\" -n %s -k runservice",
-                                 exe_path, mpm_service_name);
-        rv = ap_regkey_open(&key, AP_REGKEY_LOCAL_MACHINE, SERVICECONFIG9X,
-                            APR_READ | APR_WRITE | APR_CREATE, pconf);
-        if (rv == APR_SUCCESS) {
-            rv = ap_regkey_value_set(key, mpm_service_name,
-                                     launch_cmd, 0, pconf);
-            ap_regkey_close(key);
-        }
-        if (rv != APR_SUCCESS) {
-            ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL,
-                         "%s: Failed to add the RunServices registry entry.",
-                         mpm_display_name);
-            return (rv);
-        }
-
-        apr_snprintf(key_name, sizeof(key_name), SERVICECONFIG, mpm_service_name);
-        rv = ap_regkey_open(&key, AP_REGKEY_LOCAL_MACHINE, key_name,
-                            APR_READ | APR_WRITE | APR_CREATE, pconf);
-        if (rv != APR_SUCCESS) {
-            ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL,
-                         "%s: Failed to create the registry service key.",
-                         mpm_display_name);
-            return (rv);
-        }
-        rv = ap_regkey_value_set(key, "ImagePath", launch_cmd, 0, pconf);
-        if (rv != APR_SUCCESS) {
-            ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL,
-                         "%s: Failed to store ImagePath in the registry.",
-                         mpm_display_name);
-            ap_regkey_close(key);
-            return (rv);
-        }
-        rv = ap_regkey_value_set(key, "DisplayName",
-                                 mpm_display_name, 0, pconf);
-        ap_regkey_close(key);
-        if (rv != APR_SUCCESS) {
+        if (!schService)
+        {
+            rv = apr_get_os_error();
             ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL,
-                         "%s: Failed to store DisplayName in the registry.",
-                         mpm_display_name);
+                         "Failed to create WinNT Service Profile");
+            CloseServiceHandle(schSCManager);
             return (rv);
         }
     }
 
+    CloseServiceHandle(schService);
+    CloseServiceHandle(schSCManager);
+
     set_service_description();
 
-    /* For both WinNT & Win9x store the service ConfigArgs in the registry...
+    /* Store the service ConfigArgs in the registry...
      */
     apr_snprintf(key_name, sizeof(key_name), SERVICEPARAMS, mpm_service_name);
     rv = ap_regkey_open(&key, AP_REGKEY_LOCAL_MACHINE, key_name,
@@ -957,90 +764,52 @@
 
 apr_status_t mpm_service_uninstall(void)
 {
-    char key_name[MAX_PATH];
     apr_status_t rv;
+    SC_HANDLE schService;
+    SC_HANDLE schSCManager;
 
-    if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT)
-    {
-        SC_HANDLE schService;
-        SC_HANDLE schSCManager;
-
-        fprintf(stderr,"Removing the %s service\n", mpm_display_name);
+    fprintf(stderr,"Removing the %s service\n", mpm_display_name);
 
-        schSCManager = OpenSCManager(NULL, NULL, /* local, default database */
-                                     SC_MANAGER_CONNECT);
-        if (!schSCManager) {
-            rv = apr_get_os_error();
-            ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL,
-                         "Failed to open the WinNT service manager.");
-            return (rv);
-        }
+    schSCManager = OpenSCManager(NULL, NULL, /* local, default database */
+                                 SC_MANAGER_CONNECT);
+    if (!schSCManager) {
+        rv = apr_get_os_error();
+        ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL,
+                     "Failed to open the WinNT service manager.");
+        return (rv);
+    }
 
-        /* ###: utf-ize */
-        schService = OpenService(schSCManager, mpm_service_name, DELETE);
+    /* ###: utf-ize */
+    schService = OpenService(schSCManager, mpm_service_name, DELETE);
 
-        if (!schService) {
-           rv = apr_get_os_error();
-           ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL,
+    if (!schService) {
+        rv = apr_get_os_error();
+        ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL,
                         "%s: OpenService failed", mpm_display_name);
-           return (rv);
-        }
-
-        /* assure the service is stopped before continuing
-         *
-         * This may be out of order... we might not be able to be
-         * granted all access if the service is running anyway.
-         *
-         * And do we want to make it *this easy* for them
-         * to uninstall their service unintentionally?
-         */
-        // ap_stop_service(schService);
+        return (rv);
+    }
 
-        if (DeleteService(schService) == 0) {
-            rv = apr_get_os_error();
-            ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL,
-                         "%s: Failed to delete the service.", mpm_display_name);
-            return (rv);
-        }
+    /* assure the service is stopped before continuing
+     *
+     * This may be out of order... we might not be able to be
+     * granted all access if the service is running anyway.
+     *
+     * And do we want to make it *this easy* for them
+     * to uninstall their service unintentionally?
+     */
+    /* ap_stop_service(schService);
+     */
 
-        CloseServiceHandle(schService);
-        CloseServiceHandle(schSCManager);
+    if (DeleteService(schService) == 0) {
+        rv = apr_get_os_error();
+        ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL,
+                     "%s: Failed to delete the service.", mpm_display_name);
+        return (rv);
     }
-    else /* osver.dwPlatformId != VER_PLATFORM_WIN32_NT */
-    {
-        apr_status_t rv2, rv3;
-        ap_regkey_t *key;
-        fprintf(stderr,"Removing the %s service\n", mpm_display_name);
-
-        /* TODO: assure the service is stopped before continuing */
-
-        rv = ap_regkey_open(&key, AP_REGKEY_LOCAL_MACHINE, SERVICECONFIG9X,
-                            APR_READ | APR_WRITE | APR_CREATE, pconf);
-        if (rv == APR_SUCCESS) {
-            rv = ap_regkey_value_remove(key, mpm_service_name, pconf);
-            ap_regkey_close(key);
-        }
-        if (rv != APR_SUCCESS) {
-            ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL,
-                         "%s: Failed to remove the RunServices registry "
-                         "entry.", mpm_display_name);
-        }
 
-        /* we blast Services/us, not just the Services/us/Parameters branch */
-        apr_snprintf(key_name, sizeof(key_name), SERVICEPARAMS, mpm_service_name);
-        rv2 = ap_regkey_remove(AP_REGKEY_LOCAL_MACHINE, key_name, pconf);
-        apr_snprintf(key_name, sizeof(key_name), SERVICECONFIG, mpm_service_name);
-        rv3 = ap_regkey_remove(AP_REGKEY_LOCAL_MACHINE, key_name, pconf);
-        rv2 = (rv2 != APR_SUCCESS) ? rv2 : rv3;
-        if (rv2 != APR_SUCCESS) {
-            ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv2, NULL,
-                         "%s: Failed to remove the service config from the "
-                         "registry.", mpm_display_name);
-        }
-        rv = (rv != APR_SUCCESS) ? rv : rv2;
-        if (rv != APR_SUCCESS)
-            return rv;
-    }
+    CloseServiceHandle(schService);
+    CloseServiceHandle(schSCManager);
+
     fprintf(stderr,"The %s service has been removed successfully.\n", mpm_display_name);
     return APR_SUCCESS;
 }
@@ -1072,132 +841,57 @@
                                const char * const * argv)
 {
     apr_status_t rv;
+    char **start_argv;
+    SC_HANDLE   schService;
+    SC_HANDLE   schSCManager;
 
     fprintf(stderr,"Starting the %s service\n", mpm_display_name);
 
-    if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT)
-    {
-        char **start_argv;
-        SC_HANDLE   schService;
-        SC_HANDLE   schSCManager;
-
-        schSCManager = OpenSCManager(NULL, NULL, /* local, default database */
-                                     SC_MANAGER_CONNECT);
-        if (!schSCManager) {
-            rv = apr_get_os_error();
-            ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL,
-                         "Failed to open the WinNT service manager");
-            return (rv);
-        }
-
-        /* ###: utf-ize */
-        schService = OpenService(schSCManager, mpm_service_name,
-                                 SERVICE_START | SERVICE_QUERY_STATUS);
-        if (!schService) {
-            rv = apr_get_os_error();
-            ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL,
-                         "%s: Failed to open the service.", mpm_display_name);
-            CloseServiceHandle(schSCManager);
-            return (rv);
-        }
-
-        if (QueryServiceStatus(schService, &globdat.ssStatus)
-            && (globdat.ssStatus.dwCurrentState == SERVICE_RUNNING)) {
-            ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, 0, NULL,
-                         "Service %s is already started!", mpm_display_name);
-            CloseServiceHandle(schService);
-            CloseServiceHandle(schSCManager);
-            return 0;
-        }
-
-        start_argv = malloc((argc + 1) * sizeof(const char **));
-        memcpy(start_argv, argv, argc * sizeof(const char **));
-        start_argv[argc] = NULL;
-
-        rv = APR_EINIT;
-        /* ###: utf-ize */
-        if (StartService(schService, argc, start_argv)
-            && signal_service_transition(schService, 0, /* test only */
-                                         SERVICE_START_PENDING,
-                                         SERVICE_RUNNING))
-                rv = APR_SUCCESS;
+    schSCManager = OpenSCManager(NULL, NULL, /* local, default database */
+                                 SC_MANAGER_CONNECT);
+    if (!schSCManager) {
+        rv = apr_get_os_error();
+        ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL,
+                     "Failed to open the WinNT service manager");
+        return (rv);
+    }
 
-        if (rv != APR_SUCCESS)
-            rv = apr_get_os_error();
+    /* ###: utf-ize */
+    schService = OpenService(schSCManager, mpm_service_name,
+                             SERVICE_START | SERVICE_QUERY_STATUS);
+    if (!schService) {
+        rv = apr_get_os_error();
+        ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL,
+                     "%s: Failed to open the service.", mpm_display_name);
+        CloseServiceHandle(schSCManager);
+        return (rv);
+    }
 
+    if (QueryServiceStatus(schService, &globdat.ssStatus)
+        && (globdat.ssStatus.dwCurrentState == SERVICE_RUNNING)) {
+        ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, 0, NULL,
+                     "Service %s is already started!", mpm_display_name);
         CloseServiceHandle(schService);
         CloseServiceHandle(schSCManager);
+        return 0;
     }
-    else /* osver.dwPlatformId != VER_PLATFORM_WIN32_NT */
-    {
-        STARTUPINFO si;           /* Filled in prior to call to CreateProcess */
-        PROCESS_INFORMATION pi;   /* filled in on call to CreateProcess */
-        char exe_path[MAX_PATH];
-        char exe_cmd[MAX_PATH * 4];
-        char *next_arg;
-        int i;
-
-        /* Locate the active top level window named service_name
-         * provided the class is ApacheWin95ServiceMonitor
-         */
-        if (FindWindow("ApacheWin95ServiceMonitor", mpm_service_name)) {
-            ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, 0, NULL,
-                         "Service %s is already started!", mpm_display_name);
-            return 0;
-        }
-
-        /* This may not appear intuitive, but Win9x will not allow a process
-         * to detach from the console without releasing the entire console.
-         * Ergo, we must spawn a new process for the service to get back our
-         * console window.
-         * The config is pre-flighted, so there should be no danger of failure.
-         */
-
-        if (GetModuleFileName(NULL, exe_path, sizeof(exe_path)) == 0)
-        {
-            apr_status_t rv = apr_get_os_error();
-            ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL,
-                         "GetModuleFileName failed");
-            return rv;
-        }
-
-        apr_snprintf(exe_cmd, sizeof(exe_cmd),
-                     "\"%s\" -n %s -k runservice",
-                     exe_path, mpm_service_name);
-        next_arg = strchr(exe_cmd, '\0');
-        for (i = 0; i < argc; ++i) {
-            apr_snprintf(next_arg, sizeof(exe_cmd) - (next_arg - exe_cmd),
-                         " \"%s\"", argv[i]);
-            next_arg = strchr(exe_cmd, '\0');
-        }
 
-        memset(&si, 0, sizeof(si));
-        memset(&pi, 0, sizeof(pi));
-        si.cb = sizeof(si);
-        si.dwFlags     = STARTF_USESHOWWINDOW;
-        si.wShowWindow = SW_HIDE;   /* This might be redundant */
-
-        rv = APR_EINIT;
-        if (CreateProcess(NULL, exe_cmd, NULL, NULL, FALSE,
-                           DETACHED_PROCESS, /* Creation flags */
-                           NULL, NULL, &si, &pi))
-        {
-            DWORD code;
-            while (GetExitCodeProcess(pi.hProcess, &code) == STILL_ACTIVE) {
-                if (FindWindow("ApacheWin95ServiceMonitor", mpm_service_name)) {
-                    rv = APR_SUCCESS;
-                    break;
-                }
-                Sleep (1000);
-            }
-        }
+    start_argv = malloc((argc + 1) * sizeof(const char **));
+    memcpy(start_argv, argv, argc * sizeof(const char **));
+    start_argv[argc] = NULL;
 
-        if (rv != APR_SUCCESS)
-            rv = apr_get_os_error();
+    rv = APR_EINIT;
+    /* ###: utf-ize */
+    if (StartService(schService, argc, start_argv)
+        && signal_service_transition(schService, 0, /* test only */
+                                     SERVICE_START_PENDING,
+                                     SERVICE_RUNNING))
+        rv = APR_SUCCESS;
+    if (rv != APR_SUCCESS)
+        rv = apr_get_os_error();
 
-        CloseHandle(pi.hProcess);
-        CloseHandle(pi.hThread);
-    }
+    CloseServiceHandle(schService);
+    CloseServiceHandle(schSCManager);
 
     if (rv == APR_SUCCESS)
         fprintf(stderr,"The %s service is running.\n", mpm_display_name);
@@ -1215,129 +909,69 @@
 void mpm_signal_service(apr_pool_t *ptemp, int signal)
 {
     int success = FALSE;
+    SC_HANDLE   schService;
+    SC_HANDLE   schSCManager;
 
-    if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT)
-    {
-        SC_HANDLE   schService;
-        SC_HANDLE   schSCManager;
-
-        schSCManager = OpenSCManager(NULL, NULL, // default machine & database
-                                     SC_MANAGER_CONNECT);
-
-        if (!schSCManager) {
-            ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, apr_get_os_error(), NULL,
-                         "Failed to open the NT Service Manager");
-            return;
-        }
-
-        /* ###: utf-ize */
-        schService = OpenService(schSCManager, mpm_service_name,
-                                 SERVICE_INTERROGATE | SERVICE_QUERY_STATUS |
-                                 SERVICE_USER_DEFINED_CONTROL |
-                                 SERVICE_START | SERVICE_STOP);
-
-        if (schService == NULL) {
-            /* Could not open the service */
-            ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, apr_get_os_error(), NULL,
-                         "Failed to open the %s Service", mpm_display_name);
-            CloseServiceHandle(schSCManager);
-            return;
-        }
+    schSCManager = OpenSCManager(NULL, NULL, // default machine & database
+                                 SC_MANAGER_CONNECT);
 
-        if (!QueryServiceStatus(schService, &globdat.ssStatus)) {
-            ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, apr_get_os_error(), NULL,
-                         "Query of Service %s failed", mpm_display_name);
-            CloseServiceHandle(schService);
-            CloseServiceHandle(schSCManager);
-            return;
-        }
-
-        if (!signal && (globdat.ssStatus.dwCurrentState == SERVICE_STOPPED)) {
-            fprintf(stderr,"The %s service is not started.\n", mpm_display_name);
-            CloseServiceHandle(schService);
-            CloseServiceHandle(schSCManager);
-            return;
-        }
-
-        fprintf(stderr,"The %s service is %s.\n", mpm_display_name,
-               signal ? "restarting" : "stopping");
+    if (!schSCManager) {
+        ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, apr_get_os_error(), NULL,
+                     "Failed to open the NT Service Manager");
+        return;
+    }
 
-        if (!signal)
-            success = signal_service_transition(schService,
-                                                SERVICE_CONTROL_STOP,
-                                                SERVICE_STOP_PENDING,
-                                                SERVICE_STOPPED);
-        else if (globdat.ssStatus.dwCurrentState == SERVICE_STOPPED) {
-            mpm_service_start(ptemp, 0, NULL);
-            CloseServiceHandle(schService);
-            CloseServiceHandle(schSCManager);
-            return;
-        }
-        else
-            success = signal_service_transition(schService,
-                                                SERVICE_APACHE_RESTART,
-                                                SERVICE_START_PENDING,
-                                                SERVICE_RUNNING);
+    /* ###: utf-ize */
+    schService = OpenService(schSCManager, mpm_service_name,
+                             SERVICE_INTERROGATE | SERVICE_QUERY_STATUS |
+                             SERVICE_USER_DEFINED_CONTROL |
+                             SERVICE_START | SERVICE_STOP);
+
+    if (schService == NULL) {
+        /* Could not open the service */
+        ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, apr_get_os_error(), NULL,
+                     "Failed to open the %s Service", mpm_display_name);
+        CloseServiceHandle(schSCManager);
+        return;
+    }
 
+    if (!QueryServiceStatus(schService, &globdat.ssStatus)) {
+        ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, apr_get_os_error(), NULL,
+                     "Query of Service %s failed", mpm_display_name);
         CloseServiceHandle(schService);
         CloseServiceHandle(schSCManager);
+        return;
     }
-    else /* !isWindowsNT() */
-    {
-        DWORD       service_pid;
-        HANDLE      hwnd;
-        char prefix[20];
-        /* Locate the active top level window named service_name
-         * provided the class is ApacheWin95ServiceMonitor
-         */
-        hwnd = FindWindow("ApacheWin95ServiceMonitor", mpm_service_name);
-        if (hwnd && GetWindowThreadProcessId(hwnd, &service_pid))
-            globdat.ssStatus.dwCurrentState = SERVICE_RUNNING;
-        else
-        {
-            globdat.ssStatus.dwCurrentState = SERVICE_STOPPED;
-            if (!signal) {
-                fprintf(stderr,"The %s service is not started.\n", mpm_display_name);
-                return;
-            }
-        }
 
-        fprintf(stderr,"The %s service is %s.\n", mpm_display_name,
-               signal ? "restarting" : "stopping");
+    if (!signal && (globdat.ssStatus.dwCurrentState == SERVICE_STOPPED)) {
+        fprintf(stderr,"The %s service is not started.\n", mpm_display_name);
+        CloseServiceHandle(schService);
+        CloseServiceHandle(schSCManager);
+        return;
+    }
 
-        apr_snprintf(prefix, sizeof(prefix), "ap%ld", (long)service_pid);
-        setup_signal_names(prefix);
+    fprintf(stderr,"The %s service is %s.\n", mpm_display_name,
+            signal ? "restarting" : "stopping");
 
-        if (!signal)
-        {
-            int ticks = 60;
-            ap_signal_parent(SIGNAL_PARENT_SHUTDOWN);
-            while (--ticks)
-            {
-                if (!IsWindow(hwnd)) {
-                    success = TRUE;
-                    break;
-                }
-                Sleep(1000);
-            }
-        }
-        else /* !stop */
-        {
-            /* TODO: Aught to add a little test to the restart logic, and
-             * store the restart counter in the window's user dword.
-             * Then we can hang on and report a successful restart.  But
-             * that's a project for another day.
-             */
-            if (globdat.ssStatus.dwCurrentState == SERVICE_STOPPED) {
-                mpm_service_start(ptemp, 0, NULL);
-                return;
-            }
-            else {
-                success = TRUE;
-                ap_signal_parent(SIGNAL_PARENT_RESTART);
-            }
-        }
+    if (!signal)
+        success = signal_service_transition(schService,
+                                            SERVICE_CONTROL_STOP,
+                                            SERVICE_STOP_PENDING,
+                                            SERVICE_STOPPED);
+    else if (globdat.ssStatus.dwCurrentState == SERVICE_STOPPED) {
+        mpm_service_start(ptemp, 0, NULL);
+        CloseServiceHandle(schService);
+        CloseServiceHandle(schSCManager);
+        return;
     }
+    else
+        success = signal_service_transition(schService,
+                                            SERVICE_APACHE_RESTART,
+                                            SERVICE_START_PENDING,
+                                            SERVICE_RUNNING);
+
+    CloseServiceHandle(schService);
+    CloseServiceHandle(schSCManager);
 
     if (success)
         fprintf(stderr,"The %s service has %s.\n", mpm_display_name,