bjh         99/11/01 03:25:05

  Modified:    src/modules/mpm/spmt_os2 spmt_os2.c
  Log:
  OS/2: When shutting down, kill off child threads properly before shutting
  down parent thread.
  
  Revision  Changes    Path
  1.21      +32 -13    apache-2.0/src/modules/mpm/spmt_os2/spmt_os2.c
  
  Index: spmt_os2.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/mpm/spmt_os2/spmt_os2.c,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- spmt_os2.c        1999/11/01 10:58:55     1.20
  +++ spmt_os2.c        1999/11/01 11:25:04     1.21
  @@ -1524,20 +1524,39 @@
       }
   
       if (shutdown_pending) {
  -     /* Time to gracefully shut down:
  -      * Don't worry about killing child threads for now, the all die when 
the parent exits
  -      */
  +     /* Time to gracefully shut down */
  +        const char *pidfile = NULL;
  +        int slot;
  +        TID tid;
  +        ULONG rc;
   
  -     /* cleanup pid file on normal shutdown */
  -     {
  -         const char *pidfile = NULL;
  -         pidfile = ap_server_root_relative (pconf, ap_pid_fname);
  -         if ( pidfile != NULL && unlink(pidfile) == 0)
  -             ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0,
  -                             server_conf,
  -                             "removed PID file %s (pid=%ld)",
  -                             pidfile, (long)getpid());
  -     }
  +        /* Kill off running threads */
  +        for (slot=0; slot<max_daemons_limit; slot++) {
  +            if (ap_scoreboard_image->servers[slot].status != SERVER_DEAD) {
  +                tid = ap_scoreboard_image->parent[slot].tid;
  +                rc = DosKillThread(tid);
  +
  +                if (rc == 0) {
  +                    rc = DosWaitThread(&tid, DCWW_WAIT);
  +
  +                    if (rc) {
  +                        ap_log_error(APLOG_MARK, 
APLOG_NOERRNO|APLOG_WARNING, 0, server_conf,
  +                                     "error %lu waiting for thread to 
terminate", rc);
  +                    }
  +                } else {
  +                    ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, 
server_conf,
  +                                 "error %lu killing thread", rc);
  +                }
  +            }
  +        }
  +
  +        /* cleanup pid file on normal shutdown */
  +        pidfile = ap_server_root_relative (pconf, ap_pid_fname);
  +        if ( pidfile != NULL && unlink(pidfile) == 0)
  +            ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0,
  +                            server_conf,
  +                            "removed PID file %s (pid=%ld)",
  +                            pidfile, (long)getpid());
   
        ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0, server_conf,
                    "caught SIGTERM, shutting down");
  
  
  

Reply via email to