stoddard    00/02/15 13:20:44

  Modified:    src/modules/mpm/winnt winnt.c
  Log:
  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.
  
  Revision  Changes    Path
  1.40      +12 -49    apache-2.0/src/modules/mpm/winnt/winnt.c
  
  Index: winnt.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/mpm/winnt/winnt.c,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- winnt.c   2000/02/14 22:01:08     1.39
  +++ winnt.c   2000/02/15 21:20:39     1.40
  @@ -99,7 +99,7 @@
   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 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 @@
                            "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 @@
           }
           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;
       }
  
  
  

Reply via email to