]> granicus.if.org Git - apache/commitdiff
OS/2: When shutting down, kill off child threads properly before shutting
authorBrian Havard <bjh@apache.org>
Mon, 1 Nov 1999 11:25:04 +0000 (11:25 +0000)
committerBrian Havard <bjh@apache.org>
Mon, 1 Nov 1999 11:25:04 +0000 (11:25 +0000)
down parent thread.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@84083 13f79535-47bb-0310-9956-ffa450edef68

server/mpm/spmt_os2/spmt_os2.c

index 9487b0eba672fef93d6b33bf9374bd5b501b631f..ceb64e5be1585b733df2bb4d24d7d51dae1a25ca 100644 (file)
@@ -1524,20 +1524,39 @@ int ap_mpm_run(ap_context_t *_pconf, ap_context_t *plog, server_rec *s)
     }
 
     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;
+
+        /* 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 */
-       {
-           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());
-       }
+        /* 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");