From 86710b4ef22e1beab090443876ef1de470412f37 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 19 Oct 2018 16:25:24 -0500 Subject: [PATCH] global/signal_handler: Mutex -> ceph::mutex Signed-off-by: Sage Weil --- src/global/signal_handler.cc | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/global/signal_handler.cc b/src/global/signal_handler.cc index 59e849b2e1a71..8e4f6f5e1a891 100644 --- a/src/global/signal_handler.cc +++ b/src/global/signal_handler.cc @@ -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]); -- 2.39.5