From: Bill Stoddard Date: Tue, 15 Feb 2000 21:20:39 +0000 (+0000) Subject: Don't close the duplicated AcceptEx completion port handle in the parent. X-Git-Tag: 1.3.12~18 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4da04aa7ad5e9b8b26a6e109e15430526caede7a;p=apache Don't close the duplicated AcceptEx completion port handle in the parent. Check the return code when duplicating the acceptex completion port. Get rid of the event routine wrappers. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@84623 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/server/mpm/winnt/mpm_winnt.c b/server/mpm/winnt/mpm_winnt.c index ed2af726fc..12cfd81ba9 100644 --- a/server/mpm/winnt/mpm_winnt.c +++ b/server/mpm/winnt/mpm_winnt.c @@ -99,7 +99,7 @@ static OSVERSIONINFO osver; /* VER_PLATFORM_WIN32_NT */ int ap_max_requests_per_child=0; int ap_daemons_to_start=0; -event *exit_event; +static event *exit_event; ap_lock_t *start_mutex; int my_pid; int parent_pid; @@ -167,44 +167,6 @@ static void destroy_semaphore(semaphore *semaphore_id) } -static event * -create_event(int manual, int initial, char *name) -{ - return(CreateEvent(NULL, manual, initial, name)); -} - -static event * -open_event(char *name) -{ - return(OpenEvent(EVENT_ALL_ACCESS, FALSE, name)); -} - - -static int acquire_event(event *event_id) -{ - int rv; - - rv = WaitForSingleObject(event_id, INFINITE); - - return(map_rv(rv)); -} - -static int set_event(event *event_id) -{ - return(SetEvent(event_id)); -} - -static int reset_event(event *event_id) -{ - return(ResetEvent(event_id)); -} - - -static void destroy_event(event *event_id) -{ - CloseHandle(event_id); -} - /* To share the semaphores with other processes, we need a NULL ACL * Code from MS KB Q106387 */ @@ -1483,15 +1445,14 @@ static int create_process(ap_context_t *p, HANDLE *handles, HANDLE *events, int "Parent: BytesWritten = %d WSAProtocolInfo = %x20", BytesWritten, *lpWSAProtocolInfo); } /* Now, send the AcceptEx completion port to the child */ - DuplicateHandle(GetCurrentProcess(), - AcceptExCompPort, - pi.hProcess, - &hDupedCompPort, - 0, - TRUE, // handle can be inherited - DUPLICATE_SAME_ACCESS); + if (!DuplicateHandle(GetCurrentProcess(), AcceptExCompPort, + pi.hProcess, &hDupedCompPort, 0, + TRUE, DUPLICATE_SAME_ACCESS)) { + ap_log_error(APLOG_MARK, APLOG_CRIT, GetLastError(), server_conf, + "Parent: Unable to duplicate AcceptEx completion port. Shutting down."); + return -1; + } WriteFile(hPipeWrite, &hDupedCompPort, (DWORD) sizeof(hDupedCompPort), &BytesWritten, (LPOVERLAPPED) NULL); - CloseHandle(hDupedCompPort); } CloseHandle(hPipeRead); @@ -1716,14 +1677,16 @@ API_EXPORT(int) ap_mpm_run(ap_context_t *_pconf, ap_context_t *plog, server_rec } else { ap_child_init_lock(&start_mutex, signal_name_prefix, pconf); - exit_event = open_event(exit_event_name); + exit_event = OpenEvent(EVENT_ALL_ACCESS, FALSE, exit_event_name); + ap_log_error(APLOG_MARK, APLOG_INFO, APR_SUCCESS, server_conf, + "Child %d: exit_event_name = %s", my_pid, exit_event_name); } ap_assert(start_mutex); ap_assert(exit_event); child_main(); - destroy_event(exit_event); + CloseHandle(exit_event); AMCSocketCleanup(); restart = 0; }