]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
msgr, common: Refactor to extract daemonization out of messenger.
authorTommi Virtanen <tommi.virtanen@dreamhost.com>
Fri, 29 Apr 2011 18:29:42 +0000 (11:29 -0700)
committerTommi Virtanen <tommi.virtanen@dreamhost.com>
Fri, 29 Apr 2011 20:17:30 +0000 (13:17 -0700)
Signed-off-by: Tommi Virtanen <tommi.virtanen@dreamhost.com>
16 files changed:
src/cfuse.cc
src/cmds.cc
src/cmon.cc
src/common/common_init.cc
src/cosd.cc
src/csyn.cc
src/dumpjournal.cc
src/libceph.cc
src/librados.cc
src/mds/Dumper.cc
src/mds/Resetter.cc
src/mon/MonClient.cc
src/msg/SimpleMessenger.cc
src/msg/SimpleMessenger.h
src/testmsgr.cc
src/tools/common.cc

index ab8203420102ff451c35aefed6c27113aae19055..6c047a0bf221f9fe617c6f550e6df5e6eb37b072 100644 (file)
@@ -118,7 +118,7 @@ int main(int argc, const char **argv, const char *envp[]) {
 
     cout << "cfuse[" << getpid() << "]: starting ceph client" << std::endl;
 
-    messenger->start_with_nonce(false, getpid()); // Do not daemonize here
+    messenger->start_with_nonce(getpid());
 
     // start client
     client->init();
index 4038d77ad747a9efa70662190168fcbbc3262ce8..0ad19a4a4ab391a9e73d51c88ad2837f86d54cfc 100644 (file)
@@ -163,7 +163,9 @@ int main(int argc, const char **argv)
     messenger->set_policy(entity_name_t::TYPE_CLIENT,
                           SimpleMessenger::Policy::stateful_server(supported, 0));
 
-    messenger->start((shadow == MDSMap::STATE_ONESHOT_REPLAY ? false : g_conf.daemonize));
+    if (shadow == MDSMap::STATE_ONESHOT_REPLAY ? false : g_conf.daemonize)
+      common_init_daemonize(&g_conf);
+    messenger->start();
 
     // start mds
     MDS *mds = new MDS(g_conf.name.get_id().c_str(), messenger, &mc);
index d40094b29b2ff1c8b916244bbb007ba7bb6f5124..7fc742b0ca40868a0740b996acd5455ee0fc5c73 100644 (file)
@@ -260,7 +260,9 @@ int main(int argc, const char **argv)
   messenger->set_default_send_priority(CEPH_MSG_PRIO_HIGH);
   Monitor *mon = new Monitor(g_conf.name.get_id(), &store, messenger, &monmap);
 
-  messenger->start(g_conf.daemonize);
+  if (g_conf.daemonize)
+    common_init_daemonize(&g_conf);
+  messenger->start();
 
   uint64_t supported =
     CEPH_FEATURE_UID |
index 54e8f9ae5e162e8916c98e54716360fbacb6b08b..a96aba45edbdd9d16a7e33fa76a5ff7f875b7d54 100644 (file)
@@ -27,6 +27,8 @@
 #include "common/signal.h"
 #include "common/version.h"
 #include "include/color.h"
+#include "common/Thread.h"
+#include "common/pidfile.h"
 
 #include <errno.h>
 #include <deque>
index 1287079baa397b5e5f468db8bde4a0401877b15b..e9d12bee4b65570989abebe204d9a54dbb6777f8 100644 (file)
@@ -263,9 +263,11 @@ int main(int argc, const char **argv)
     return 1;
   }
 
-  client_messenger->start(g_conf.daemonize);
-  messenger_hb->start(false);  // do not daemonize (only need to daemonize once)
-  cluster_messenger->start(false); // do not daemonize (only need to daemonize once)
+  if (g_conf.daemonize)
+    common_init_daemonize(&g_conf);
+  client_messenger->start();
+  messenger_hb->start();
+  cluster_messenger->start();
 
   // start osd
   err = osd->init();
index fff06349ad6494c6e23b15327d6686d521c5d01e..da9c90a66fac491e8838c5ee48884d97817611df 100644 (file)
@@ -75,7 +75,7 @@ int main(int argc, const char **argv, char *envp[])
     SyntheticClient *syn = new SyntheticClient(client);
     clients.push_back(client);
     synclients.push_back(syn);
-    messengers[i]->start(false); // do not daemonize
+    messengers[i]->start();
   }
 
   for (list<SyntheticClient*>::iterator p = synclients.begin(); 
index 14305a88448e0fa3195c66a8251874305ff3933d..0f6f7924f4d8204c5005b932ba19bb4301c496e2 100644 (file)
@@ -95,7 +95,7 @@ int main(int argc, const char **argv, const char *envp[])
   // start up network
   SimpleMessenger *messenger = new SimpleMessenger();
   messenger->bind(getpid());
-  messenger->start(false); // do not daemonize
+  messenger->start();
   messenger->register_entity(entity_name_t::CLIENT());
   messenger->add_dispatcher_head(&dispatcher);
 
index 8ae2177d5d30f95cb8b092aa89ca0aee9ce58d7b..bb5dd3b1b76db40ea0bc3f4dcfcdac8434aa47a2 100644 (file)
@@ -93,7 +93,7 @@ public:
       return -1002;
     }
 
-    if (messenger->start_with_nonce(false, msgr_nonce) != 0) {
+    if (messenger->start_with_nonce(msgr_nonce) != 0) {
       shutdown();
       return -1003;
     }
index 80c622de7995815c95a5f79ad09ac9b2a8895ac4..7fa4741b46dc0d0bd3c1cdb0dd80ae1694bd9a95 100644 (file)
@@ -649,7 +649,7 @@ connect()
   rados_instance.inc();
   nonce = getpid() + (1000000 * (uint64_t)rados_instance.read());
 
-  messenger->start_with_nonce(false, nonce); // do not daemonize
+  messenger->start_with_nonce(nonce);
   messenger->add_dispatcher_head(this);
 
   dout(1) << "setting wanted keys" << dendl;
index d029f7de9f48ef2e58f8620dfbe0a4de73b3ae00..6a61ce8aae90418d6deedd6b7d1261cbccc458a6 100644 (file)
@@ -56,7 +56,7 @@ void Dumper::init(int rank)
 
   messenger->register_entity(entity_name_t::CLIENT());
   messenger->add_dispatcher_head(this);
-  messenger->start_with_nonce(false, getpid()); // do not daemonize
+  messenger->start_with_nonce(getpid());
 
   monc->set_want_keys(CEPH_ENTITY_TYPE_MON|CEPH_ENTITY_TYPE_OSD|CEPH_ENTITY_TYPE_MDS);
   monc->set_messenger(messenger);
index 2dc1b0fac7ce6732649ff897c703697a8f12ae24..017ee3186c2bb79ba0b1890d03f591d1f74fbfbb 100644 (file)
@@ -50,7 +50,7 @@ void Resetter::init(int rank)
 
   messenger->register_entity(entity_name_t::CLIENT());
   messenger->add_dispatcher_head(this);
-  messenger->start_with_nonce(false, getpid());
+  messenger->start_with_nonce(getpid());
 
   monc->set_want_keys(CEPH_ENTITY_TYPE_MON|CEPH_ENTITY_TYPE_OSD|CEPH_ENTITY_TYPE_MDS);
   monc->set_messenger(messenger);
index e8b2abd74a6e0b06c1f955cf901434c31dadf66e..c932cd560559fec74631ddd01d3d60cdb01dcfbb 100644 (file)
@@ -189,7 +189,7 @@ int MonClient::get_monmap_privately()
     messenger = smessenger = new SimpleMessenger();
     smessenger->register_entity(entity_name_t::CLIENT(-1));
     messenger->add_dispatcher_head(this);
-    smessenger->start_with_nonce(false, getpid());  // do not daemonize!
+    smessenger->start_with_nonce(getpid());
     temp_msgr = true; 
   }
   
index 134c0dd62cd8e4bb909bc6c74642c049e7066eb6..a2f04436e7079c7da23a0a5e6a78ad77bcf16077 100644 (file)
@@ -2317,7 +2317,7 @@ int SimpleMessenger::rebind(int avoid_port)
   return accepter.rebind(avoid_port);
 }
 
-int SimpleMessenger::start_with_nonce(bool daemonize, uint64_t nonce)
+int SimpleMessenger::start_with_nonce(uint64_t nonce)
 {
   lock.Lock();
   dout(1) << "messenger.start" << dendl;
@@ -2333,11 +2333,6 @@ int SimpleMessenger::start_with_nonce(bool daemonize, uint64_t nonce)
 
   lock.Unlock();
 
-  if (daemonize) {
-    common_init_daemonize(&g_conf);
-  }
-
-  // go!
   if (did_bind)
     accepter.start();
 
index 753faa7370b6821220ef2321f9d54402faca8fb5..b285ff9e5a9f5d11b63fc23d6c2d2c1ba2abb248 100644 (file)
@@ -564,10 +564,10 @@ public:
   int bind(uint64_t nonce) {
     return bind(g_conf.public_addr, nonce);
   }
-  int start_with_nonce(bool daemonize, uint64_t nonce);  // if we didn't bind
-  int start(bool daemonize) {                 // if we did
+  int start_with_nonce(uint64_t nonce);  // if we didn't bind
+  int start() {                 // if we did
     assert(did_bind);
-    return start_with_nonce(daemonize, 0);
+    return start_with_nonce(0);
   }
   void wait();
 
index 15aa662e468b4967557d22c8ffafa7377635dff6..18a50ffe75c66f87437182ecb8af706a1a512cd0 100644 (file)
@@ -96,7 +96,7 @@ int main(int argc, const char **argv, const char *envp[]) {
   messenger->set_default_send_priority(CEPH_MSG_PRIO_HIGH);
   messenger->add_dispatcher_head(&dispatcher);
 
-  rank->start(false); // do not daemonize
+  rank->start();
   
   int isend = 0;
   if (whoami == 0)
index 1d614432c169c19da54e48c19c1b44bf4f718827..dda210977242eb0cd45e0e6a294104f6047cc5a8 100644 (file)
@@ -523,7 +523,7 @@ int ceph_tool_common_init(ceph_tool_mode_t mode)
   // start up network
   messenger = new SimpleMessenger();
   messenger->register_entity(entity_name_t::CLIENT());
-  messenger->start_with_nonce(false, getpid()); // do not daemonize
+  messenger->start_with_nonce(getpid());
   messenger->add_dispatcher_head(&dispatcher);
 
   g.lock.Lock();