httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject cvs commit: httpd-2.0/server/mpm/winnt mpm_winnt.c
Date Tue, 12 Feb 2002 00:14:47 GMT
wrowe       02/02/11 16:14:47

  Modified:    server/mpm/winnt mpm_winnt.c
  Log:
    Perform a serious scrubbing of the child process, before we report that
    we failed to create the child.  Cleans up CloseHandle() destruction to
    match all created handles - and postpone populating the *child_exit_event
    until we succeed.
  
  Revision  Changes    Path
  1.235     +23 -5     httpd-2.0/server/mpm/winnt/mpm_winnt.c
  
  Index: mpm_winnt.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/winnt/mpm_winnt.c,v
  retrieving revision 1.234
  retrieving revision 1.235
  diff -u -r1.234 -r1.235
  --- mpm_winnt.c	11 Feb 2002 23:34:10 -0000	1.234
  +++ mpm_winnt.c	12 Feb 2002 00:14:47 -0000	1.235
  @@ -1434,6 +1434,7 @@
       HANDLE hPipeWrite;
       HANDLE hNullOutput;
       HANDLE hShareError;
  +    HANDLE hExitEvent;
       HANDLE hCurrentProcess = GetCurrentProcess();
       SECURITY_ATTRIBUTES sa;
   
  @@ -1530,8 +1531,8 @@
       }
   
       /* Create the child_exit_event */
  -    *child_exit_event = CreateEvent(NULL, TRUE, FALSE, NULL);
  -    if (!(*child_exit_event)) {
  +    hExitEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
  +    if (!hExitEvent) {
           ap_log_error(APLOG_MARK, APLOG_CRIT, apr_get_os_error(), ap_server_conf,
                        "Parent: Could not create exit event for child process");
           CloseHandle(hPipeWrite);
  @@ -1587,7 +1588,7 @@
                          NULL,
                          &si, &pi);
   
  -    /* Undo everything we created for the child only
  +    /* Undo everything created for the child alone
        */
       CloseHandle(pi.hThread);
       CloseHandle(hPipeRead);
  @@ -1604,17 +1605,25 @@
       if (!rv) {
           ap_log_error(APLOG_MARK, APLOG_CRIT, apr_get_os_error(), ap_server_conf,
                        "Parent: Failed to create the child process.");
  +        CloseHandle(hExitEvent);
           CloseHandle(hPipeWrite);
           CloseHandle(pi.hProcess);
  -        CloseHandle(pi.hThread);
           return -1;
       }
   
       ap_log_error(APLOG_MARK, APLOG_INFO, APR_SUCCESS, ap_server_conf,
                    "Parent: Created child process %d", pi.dwProcessId);
   
  -    if (send_handles_to_child(p, *child_exit_event, pi.hProcess, hPipeWrite)) {
  +    if (send_handles_to_child(p, hExitEvent, pi.hProcess, hPipeWrite)) {
  +        /*
  +         * This error is fatal, mop up the child and move on
  +         * We toggle the child's exit event to cause this child 
  +         * to quit even as it is attempting to start.
  +         */
  +        SetEvent(hExitEvent);
  +        CloseHandle(hExitEvent);
           CloseHandle(hPipeWrite);
  +        CloseHandle(pi.hProcess);
           return -1;
       }
   
  @@ -1629,13 +1638,22 @@
       Sleep(1000);
   
       if (send_listeners_to_child(p, pi.dwProcessId, hPipeWrite)) {
  +        /*
  +         * This error is fatal, mop up the child and move on
  +         * We toggle the child's exit event to cause this child 
  +         * to quit even as it is attempting to start.
  +         */
  +        SetEvent(hExitEvent);
  +        CloseHandle(hExitEvent);
           CloseHandle(hPipeWrite);        
  +        CloseHandle(pi.hProcess);
           return -1;
       }
   
       CloseHandle(hPipeWrite);        
   
       *child_proc = pi.hProcess;
  +    *child_exit_event = hExitEvent;
   
       return 0;
   }
  
  
  

Mime
View raw message