From 1ef7c3d4151fe6e49f47503c0e1a9f7067d802f1 Mon Sep 17 00:00:00 2001 From: Brian Havard Date: Mon, 1 Nov 1999 11:25:04 +0000 Subject: [PATCH] OS/2: When shutting down, kill off child threads properly before shutting 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 | 45 ++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/server/mpm/spmt_os2/spmt_os2.c b/server/mpm/spmt_os2/spmt_os2.c index 9487b0eba6..ceb64e5be1 100644 --- a/server/mpm/spmt_os2/spmt_os2.c +++ b/server/mpm/spmt_os2/spmt_os2.c @@ -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; slotservers[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"); -- 2.40.0