httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@apache.org
Subject cvs commit: httpd-2.0/server/mpm/mpmt_os2 mpmt_os2_child.c mpmt_os2.c
Date Mon, 20 Aug 2001 16:10:57 GMT
bjh         01/08/20 09:10:57

  Modified:    server/mpm/mpmt_os2 mpmt_os2_child.c mpmt_os2.c
  Log:
  Catch exceptions in worker threads so a segfault doesn't kill all active
  connections in the process. When this occurs, a graceful shutdown of the
  child is initiated so any leaked resources & hosed memory is disposed of ASAP.
  
  Revision  Changes    Path
  1.2       +37 -0     httpd-2.0/server/mpm/mpmt_os2/mpmt_os2_child.c
  
  Index: mpmt_os2_child.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/mpmt_os2/mpmt_os2_child.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- mpmt_os2_child.c	2001/08/17 17:07:34	1.1
  +++ mpmt_os2_child.c	2001/08/20 16:10:57	1.2
  @@ -340,6 +340,39 @@
   
   
   
  +ULONG APIENTRY thread_exception_handler(EXCEPTIONREPORTRECORD *pReportRec,
  +                                        EXCEPTIONREGISTRATIONRECORD *pRegRec,
  +                                        CONTEXTRECORD *pContext,
  +                                        PVOID p)
  +{
  +    int c;
  +
  +    if (pReportRec->fHandlerFlags & EH_NESTED_CALL) {
  +        return XCPT_CONTINUE_SEARCH;
  +    }
  +
  +    if (pReportRec->ExceptionNum == XCPT_ACCESS_VIOLATION ||
  +        pReportRec->ExceptionNum == XCPT_INTEGER_DIVIDE_BY_ZERO) {
  +        ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, ap_server_conf,
  +                     "caught exception in worker thread, initiating child shutdown pid=%d",
getpid());
  +        for (c=0; c<HARD_THREAD_LIMIT; c++) {
  +            if (ap_scoreboard_image->servers[child_slot][c].tid == _gettid()) {
  +                ap_scoreboard_image->servers[child_slot][c].status = SERVER_DEAD;
  +                break;
  +            }
  +        }
  +
  +        /* Shut down process ASAP, it could be quite unhealthy & leaking resources
*/
  +        shutdown_pending = 1;
  +        ap_scoreboard_image->parent[child_slot].quiescing = 1;
  +        DosUnwindException(UNWIND_ALL, 0, 0);
  +    }
  +  
  +    return XCPT_CONTINUE_SEARCH;
  +}
  +
  +
  +
   static void worker_main(void *vpArg)
   {
       long conn_id;
  @@ -353,6 +386,10 @@
       ULONG len;
       BYTE priority;
       int thread_slot = (int)vpArg;
  +    EXCEPTIONREGISTRATIONRECORD reg_rec = { NULL, thread_exception_handler };
  +  
  +    /* Trap exceptions in this thread so we don't take down the whole process */
  +    DosSetExceptionHandler( &reg_rec );
   
       rc = DosOpenQueue(&owner, &workq,
                         apr_psprintf(pchild, "/queues/httpd/work.%d", getpid()));
  
  
  
  1.4       +0 -1      httpd-2.0/server/mpm/mpmt_os2/mpmt_os2.c
  
  Index: mpmt_os2.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/mpmt_os2/mpmt_os2.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- mpmt_os2.c	2001/08/20 10:58:09	1.3
  +++ mpmt_os2.c	2001/08/20 16:10:57	1.4
  @@ -77,7 +77,6 @@
   /*
    Todo list
    - Enforce MaxClients somehow
  - - Catch thread exceptions & initiate graceful shutdown of child process
   */
   #define CORE_PRIVATE
   #define INCL_NOPMAPI
  
  
  

Mime
View raw message