From 01f3f6a620a5beb91743089807e9718288efccf5 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Mon, 19 Dec 2011 16:00:27 -0800 Subject: [PATCH] rgw: add timeout to init path --- src/common/config_opts.h | 1 + src/rgw/rgw_main.cc | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 8aadad20e0daa..80a8fafd8a714 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -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") diff --git a/src/rgw/rgw_main.cc b/src/rgw/rgw_main.cc index c4c6f929743a4..6cd7b5603f898 100644 --- a/src/rgw/rgw_main.cc +++ b/src/rgw/rgw_main.cc @@ -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(); -- 2.39.5