]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
signal_handler: Implementing specific messages per context 21000/head
authorErwan Velu <erwan@redhat.com>
Thu, 22 Mar 2018 05:25:31 +0000 (06:25 +0100)
committerErwan Velu <erwan@redhat.com>
Thu, 19 Apr 2018 07:48:36 +0000 (09:48 +0200)
As per bug #23320, regarding the signal we receive, it could be interesting providing a specific message.

If we get a SI_USER we almost print the actual message except we don't print the PID which have no meaning when set to 0.

In all other cases, we do print the full structure to help debuggers understanding the received signal.

This patch is offering a better way to get specific messages based on various si_code values.
It could be expanded later based on debugging feedbacks.

Fixes: http://tracker.ceph.com/issues/23320
Signed-off-by: Erwan Velu <erwan@redhat.com>
src/global/signal_handler.cc

index 5764fb3e8f759a2f35c53c7a8d930b823ead48a3..ae860e214560c0f19b93b2277404b5581273de44 100644 (file)
@@ -313,13 +313,33 @@ struct SignalHandler : public Thread {
            r = read(handlers[signum]->pipefd[0], &v, 1);
            if (r == 1) {
              siginfo_t * siginfo = &handlers[signum]->info_t;
-             string task_name = get_name_by_pid(siginfo->si_pid);
-             derr << "received  signal: " << sig_str(signum)
-                  << " from " << " PID: " << siginfo->si_pid
-                  << " task name: " << task_name
-                  << " UID: " << siginfo->si_uid
-                  << dendl;
-             handlers[signum]->handler(signum);
+              ostringstream message;
+              message << "received  signal: " << sig_str(signum);
+              switch (siginfo->si_code) {
+                case SI_USER:
+                  message << " from " << get_name_by_pid(siginfo->si_pid);
+                  // If PID is undefined, it doesn't have a meaning to be displayed
+                  if (siginfo->si_pid) {
+                    message << " (PID: " << siginfo->si_pid << ")";
+                  } else {
+                    message << " ( Could be generated by pthread_kill(), raise(), abort(), alarm() )";
+                  }
+                  message << " UID: " << siginfo->si_uid;
+                  break;
+                default:
+                  /* As we have a not expected signal, let's report the structure to help debugging */
+                  message << ", si_code : " << siginfo->si_code;
+                  message << ", si_value (int): " << siginfo->si_value.sival_int;
+                  message << ", si_value (ptr): " << siginfo->si_value.sival_ptr;
+                  message << ", si_errno: " << siginfo->si_errno;
+                  message << ", si_pid : " << siginfo->si_pid;
+                  message << ", si_uid : " << siginfo->si_uid;
+                  message << ", si_addr" << siginfo->si_addr;
+                  message << ", si_status" << siginfo->si_status;
+                  break;
+              }
+              derr << message.str() << dendl;
+              handlers[signum]->handler(signum);
            }
          }
        }