]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add timeout to init path
authorYehuda Sadeh <yehuda@hq.newdream.net>
Tue, 20 Dec 2011 00:00:27 +0000 (16:00 -0800)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Tue, 20 Dec 2011 00:01:18 +0000 (16:01 -0800)
src/common/config_opts.h
src/rgw/rgw_main.cc

index 8aadad20e0daa479ffe9a6195893b38b392d9e58..80a8fafd8a714a6226dc3695c66c9815cde834a4 100644 (file)
@@ -355,6 +355,7 @@ OPTION(rgw_log_object_name, OPT_STR, "%Y-%m-%d-%H-%i-%n")      // man date to se
 OPTION(rgw_log_object_name_utc, OPT_BOOL, false)
 OPTION(rgw_intent_log_object_name, OPT_STR, "%Y-%m-%d-%i-%n")  // man date to see codes (a subset are supported)
 OPTION(rgw_intent_log_object_name_utc, OPT_BOOL, false)
+OPTION(rgw_init_timeout, OPT_INT, 30) // time in seconds
 OPTION(rbd_writeback_window, OPT_INT, 0 /*8 << 20*/) // rbd writeback window size, bytes
 OPTION(rgw_mime_types_file, OPT_STR, "/etc/mime.types")
 
index c4c6f929743a4c182f80b7f2cd83618b9b9b9b27..6cd7b5603f898bc2b3794d0ade1c5565a694579b 100644 (file)
@@ -235,6 +235,15 @@ done:
   dout(0) << "====== req done fcgx=" << hex << fcgx << dec << " http_status=" << http_ret << " ======" << dendl;
 }
 
+class C_InitTimeout : public Context {
+public:
+  C_InitTimeout() {}
+  void finish(int r) {
+    derr << "Initialization timeout, failed to initialize" << dendl;
+    exit(1);
+  }
+};
+
 /*
  * start up the RADOS connection and then handle HTTP messages as they come in
  */
@@ -278,7 +287,13 @@ int main(int argc, const char **argv)
       dout(0) << "weird, i couldn't chdir to '" << g_conf->chdir << "'" << dendl;
     }
   }
-  
+  Mutex mutex("main");
+  SafeTimer init_timer(g_ceph_context, mutex);
+  init_timer.init();
+  mutex.Lock();
+  init_timer.add_event_after(g_conf->rgw_init_timeout, new C_InitTimeout);
+  mutex.Unlock();
+
   common_init_finish(g_ceph_context);
 
   rgw_tools_init(g_ceph_context);
@@ -301,6 +316,10 @@ int main(int argc, const char **argv)
   if (r < 0)
     return 1;
 
+  mutex.Lock();
+  init_timer.cancel_all_events();
+  mutex.Unlock();
+
   RGWProcess process(g_ceph_context, g_conf->rgw_thread_pool_size);
   process.run();