]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
config: fix signal handler recursion
authorSage Weil <sage@newdream.net>
Thu, 28 Oct 2010 19:10:29 +0000 (12:10 -0700)
committerSage Weil <sage@newdream.net>
Thu, 28 Oct 2010 19:10:56 +0000 (12:10 -0700)
Avoid having old handler pointer match the new handler.

Avoid calling an old handler if it pointer is null.

Signed-off-by: Sage Weil <sage@newdream.net>
src/config.cc

index e5d3b760b97469e1e15d870dcdd051592f961917..5f9c1cb620b89c69b4a4b1ed43b8966a1675ef17 100644 (file)
@@ -226,7 +226,8 @@ void sigsegv_handler(int signum)
   BackTrace bt(0);
   bt.print(*_dout);
 
-  old_sigsegv_handler(signum);
+  if (old_sigsegv_handler)
+    old_sigsegv_handler(signum);
 }
 
 void sigabrt_handler(int signum)
@@ -235,7 +236,9 @@ void sigabrt_handler(int signum)
   BackTrace bt(0);
   bt.print(*_dout);
 
-  old_sigabrt_handler(signum);
+  //*_dout << "i am " << (void*)sigabrt_handler << ", chaining to " << (void*)old_sigabrt_handler << std::endl;
+  if (old_sigabrt_handler)
+    old_sigabrt_handler(signum);
 }
 
 #define _STR(x) #x
@@ -1265,8 +1268,13 @@ void parse_config_options(std::vector<const char*>& args)
   signal(SIGHUP, sighup_handler);
   if (!old_sigsegv_handler)
     old_sigsegv_handler = signal(SIGSEGV, sigsegv_handler);
-  if (!old_sigabrt_handler)
+  if (!old_sigabrt_handler) {
     old_sigabrt_handler = signal(SIGABRT, sigabrt_handler);
-
+    if (old_sigabrt_handler == sigabrt_handler)
+      old_sigabrt_handler = NULL;
+    //cout << "old_sigabrt_handler is " << (void*)old_sigabrt_handler << " new value is " << (void*)sigabrt_handler << std::endl;
+  } else {
+    //cout << "old_sigabrt_handler is " << (void*)old_sigabrt_handler << " didn't change" << std::endl;
+  }
   args = nargs;
 }