]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
global/signal_handler: Mutex -> ceph::mutex
authorSage Weil <sage@redhat.com>
Fri, 19 Oct 2018 21:25:24 +0000 (16:25 -0500)
committerKefu Chai <kchai@redhat.com>
Wed, 21 Nov 2018 03:56:33 +0000 (11:56 +0800)
Signed-off-by: Sage Weil <sage@redhat.com>
src/global/signal_handler.cc

index 59e849b2e1a7102795bd9d42f93cfc38441c0ab8..8e4f6f5e1a89181978711b949d43be2c71a8d049 100644 (file)
@@ -17,7 +17,7 @@
 #include "include/compat.h"
 #include "pthread.h"
 
-#include "common/Mutex.h"
+#include "common/ceph_mutex.h"
 #include "common/BackTrace.h"
 #include "common/debug.h"
 #include "common/safe_io.h"
@@ -384,7 +384,7 @@ struct SignalHandler : public Thread {
   int pipefd[2];  // write to [1], read from [0]
 
   /// to signal shutdown
-  bool stop;
+  bool stop = false;
 
   /// for an individual signal
   struct safe_handler {
@@ -404,11 +404,9 @@ struct SignalHandler : public Thread {
   safe_handler *handlers[32] = {nullptr};
 
   /// to protect the handlers array
-  Mutex lock;
+  ceph::mutex lock = ceph::make_mutex("SignalHandler::lock");
 
-  SignalHandler()
-    : stop(false), lock("SignalHandler::lock")
-  {
+  SignalHandler() {
     // create signal pipe
     int r = pipe_cloexec(pipefd);
     ceph_assert(r == 0);
@@ -440,7 +438,7 @@ struct SignalHandler : public Thread {
       // build fd list
       struct pollfd fds[33];
 
-      lock.Lock();
+      lock.lock();
       int num_fds = 0;
       fds[num_fds].fd = pipefd[0];
       fds[num_fds].events = POLLIN | POLLERR;
@@ -454,7 +452,7 @@ struct SignalHandler : public Thread {
          ++num_fds;
        }
       }
-      lock.Unlock();
+      lock.unlock();
 
       // wait for data on any of those pipes
       int r = poll(fds, num_fds, -1);
@@ -466,7 +464,7 @@ struct SignalHandler : public Thread {
        // consume byte from signal socket, if any.
        TEMP_FAILURE_RETRY(read(pipefd[0], &v, 1));
 
-       lock.Lock();
+       lock.lock();
        for (unsigned signum=0; signum<32; signum++) {
          if (handlers[signum]) {
            r = read(handlers[signum]->pipefd[0], &v, 1);
@@ -502,7 +500,7 @@ struct SignalHandler : public Thread {
            }
          }
        }
-       lock.Unlock();
+       lock.unlock();
       } 
     }
     return NULL;
@@ -553,9 +551,9 @@ void SignalHandler::register_handler(int signum, signal_handler_t handler, bool
   ceph_assert(r == 0);
 
   h->handler = handler;
-  lock.Lock();
+  lock.lock();
   handlers[signum] = h;
-  lock.Unlock();
+  lock.unlock();
 
   // signal thread so that it sees our new handler
   signal_thread();
@@ -583,9 +581,9 @@ void SignalHandler::unregister_handler(int signum, signal_handler_t handler)
   signal(signum, SIG_DFL);
 
   // _then_ remove our handlers entry
-  lock.Lock();
+  lock.lock();
   handlers[signum] = NULL;
-  lock.Unlock();
+  lock.unlock();
 
   // this will wake up select() so that worker thread sees our handler is gone
   close(h->pipefd[0]);