TS-1736: Fatal() terminates process without a backtrace

The root casue is that cleanup_func() was called before logging
backtrace in Diags::error(), however cleanup_func() would terminate
process by calling exit() directly.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/82ce5ff1
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/82ce5ff1
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/82ce5ff1

Branch: refs/heads/3.3.x
Commit: 82ce5ff1919a0c15e44b47dba36967db0acc427b
Parents: 3f905d5
Author: Yunkai Zhang <yunkai...@gmail.com>
Authored: Tue Apr 2 11:56:30 2013 -0700
Committer: James Peach <jpe...@apache.org>
Committed: Tue Apr 2 11:58:03 2013 -0700

----------------------------------------------------------------------
 CHANGES                    |    5 ++++-
 mgmt/LocalManager.cc       |    6 ++----
 mgmt/LocalManager.h        |    2 +-
 mgmt/Main.cc               |    3 ++-
 mgmt/api/CoreAPI.cc        |    2 +-
 mgmt/cluster/ClusterCom.cc |    4 ++--
 mgmt/utils/MgmtUtils.cc    |    2 +-
 7 files changed, 13 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/82ce5ff1/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 9883ad7..04d63ad 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,9 +2,12 @@
   Changes with Apache Traffic Server 3.3.2
 
 
+  *) [TS-1736] Fatal() terminates process without a backtrace
+    Author: Yunkai Zhang <yunkai...@gmail.com>
+
   *) [TS-1791] remove m_mutex acquire&release to avoid deadlock in
    ~LogBufferList(). Author: Gang Li <que...@taobao.com>.
-   
+
   *) [TS-1713] SRV support refine. Now the srv option is able to enable, with
    no crash. Be care, the hostdb.storage_size or ostdb.size need check.
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/82ce5ff1/mgmt/LocalManager.cc
----------------------------------------------------------------------
diff --git a/mgmt/LocalManager.cc b/mgmt/LocalManager.cc
index 20a711d..aaddf18 100644
--- a/mgmt/LocalManager.cc
+++ b/mgmt/LocalManager.cc
@@ -62,7 +62,7 @@ LocalManager::mgmtCleanup()
 
 
 void
-LocalManager::mgmtShutdown(int status, bool mainThread)
+LocalManager::mgmtShutdown(bool mainThread)
 {
   if (mainThread) {
     mgmt_log("[LocalManager::mgmtShutdown] Executing shutdown request.\n");
@@ -70,7 +70,7 @@ LocalManager::mgmtShutdown(int status, bool mainThread)
     // WCCP TBD: Send a shutdown message to routers.
 
     if (processRunning()) {
-      waitpid(watched_process_pid, &status, 0);
+      waitpid(watched_process_pid, NULL, 0);
 #if defined(linux)
       /* Avert race condition, wait for the thread to complete,
          before getting one more restart process */
@@ -78,9 +78,7 @@ LocalManager::mgmtShutdown(int status, bool mainThread)
       mgmt_sleep_msec(1);
 #endif
     }
-
     mgmtCleanup();
-    _exit(status);
   } else {
     mgmt_shutdown_outstanding = true;
   }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/82ce5ff1/mgmt/LocalManager.h
----------------------------------------------------------------------
diff --git a/mgmt/LocalManager.h b/mgmt/LocalManager.h
index 92e7d65..8df0640 100644
--- a/mgmt/LocalManager.h
+++ b/mgmt/LocalManager.h
@@ -87,7 +87,7 @@ public:
   void closeProxyPorts();
 
   void mgmtCleanup();
-  void mgmtShutdown(int status, bool mainThread = false);
+  void mgmtShutdown(bool mainThread = false);
   void processShutdown(bool mainThread = false);
   void processRestart();
   void processBounce();

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/82ce5ff1/mgmt/Main.cc
----------------------------------------------------------------------
diff --git a/mgmt/Main.cc b/mgmt/Main.cc
index 2463689..3760366 100644
--- a/mgmt/Main.cc
+++ b/mgmt/Main.cc
@@ -798,7 +798,8 @@ main(int argc, char **argv)
     }
 
     if (lmgmt->mgmt_shutdown_outstanding == true) {
-      lmgmt->mgmtShutdown(0, true);
+      lmgmt->mgmtShutdown(true);
+      _exit(0);
     }
 
     if (lmgmt->run_proxy && !lmgmt->processRunning()) { /* Make sure we still 
have a proxy up */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/82ce5ff1/mgmt/api/CoreAPI.cc
----------------------------------------------------------------------
diff --git a/mgmt/api/CoreAPI.cc b/mgmt/api/CoreAPI.cc
index 43c5f30..c5a1a21 100644
--- a/mgmt/api/CoreAPI.cc
+++ b/mgmt/api/CoreAPI.cc
@@ -256,7 +256,7 @@ Restart(bool cluster)
     // this will kill TM completely;traffic_cop will restart TM/TS
     lmgmt->ccom->sendClusterMessage(CLUSTER_MSG_SHUTDOWN_MANAGER);
   } else {                      // just bounce local proxy
-    lmgmt->mgmtShutdown(0);
+    lmgmt->mgmtShutdown();
   }
 
   return TS_ERR_OKAY;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/82ce5ff1/mgmt/cluster/ClusterCom.cc
----------------------------------------------------------------------
diff --git a/mgmt/cluster/ClusterCom.cc b/mgmt/cluster/ClusterCom.cc
index 4a40c24..6f15a91 100644
--- a/mgmt/cluster/ClusterCom.cc
+++ b/mgmt/cluster/ClusterCom.cc
@@ -273,7 +273,7 @@ drainIncomingChannel(void *arg)
             delete buff;
         } else if (strstr(message, "cmd: shutdown_manager")) {
           mgmt_log("[ClusterCom::drainIncomingChannel] Received manager 
shutdown request\n");
-          lmgmt->mgmtShutdown(0);
+          lmgmt->mgmtShutdown();
         } else if (strstr(message, "cmd: shutdown_process")) {
           mgmt_log("[ClusterCom::drainIncomingChannel] Received process 
shutdown request\n");
           lmgmt->processShutdown();
@@ -1789,7 +1789,7 @@ ClusterCom::sendClusterMessage(int msg_type, const char 
*args)
 
   switch (msg_type) {
   case CLUSTER_MSG_SHUTDOWN_MANAGER:
-    lmgmt->mgmtShutdown(0);
+    lmgmt->mgmtShutdown();
     break;
   case CLUSTER_MSG_SHUTDOWN_PROCESS:
     lmgmt->processShutdown();

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/82ce5ff1/mgmt/utils/MgmtUtils.cc
----------------------------------------------------------------------
diff --git a/mgmt/utils/MgmtUtils.cc b/mgmt/utils/MgmtUtils.cc
index 6a5c40e..29d4401 100644
--- a/mgmt/utils/MgmtUtils.cc
+++ b/mgmt/utils/MgmtUtils.cc
@@ -473,7 +473,7 @@ mgmt_cleanup()
 {
 #if defined(LOCAL_MANAGER)
   if (lmgmt != NULL) {
-    lmgmt->mgmtShutdown(1, true);
+    lmgmt->mgmtShutdown(true);
   }
 #endif
 }

Reply via email to