From: Yehuda Sadeh Date: Tue, 17 Feb 2015 23:05:40 +0000 (-0800) Subject: rgw: pass civetweb configurables to civetweb X-Git-Tag: v0.80.9~2^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F3853%2Fhead;p=ceph.git rgw: pass civetweb configurables to civetweb Fixes: #10907 Backport: firefly Pass any configurables in the rgw frontends config line to civetweb. Signed-off-by: Yehuda Sadeh (cherry picked from commit 986d7554426764a149621ba733c5c075b94e0431) --- diff --git a/src/rgw/rgw_main.cc b/src/rgw/rgw_main.cc index 5fa3279da31..fc40b6493ce 100644 --- a/src/rgw/rgw_main.cc +++ b/src/rgw/rgw_main.cc @@ -144,6 +144,8 @@ public: bool get_val(const string& key, const string& def_val, string *out); bool get_val(const string& key, int def_val, int *out); + map& get_config_map() { return config_map; } + string get_framework() { return framework; } }; @@ -916,6 +918,12 @@ class RGWMongooseFrontend : public RGWFrontend { struct mg_context *ctx; RGWProcessEnv env; + void set_conf_default(map& m, const string& key, const string& def_val) { + if (m.find(key) == m.end()) { + m[key] = def_val; + } + } + public: RGWMongooseFrontend(RGWProcessEnv& pe, RGWFrontendConfig *_conf) : conf(_conf), ctx(NULL), env(pe) { } @@ -928,9 +936,23 @@ public: char thread_pool_buf[32]; snprintf(thread_pool_buf, sizeof(thread_pool_buf), "%d", (int)g_conf->rgw_thread_pool_size); string port_str; + map conf_map = conf->get_config_map(); conf->get_val("port", "80", &port_str); - const char *options[] = {"listening_ports", port_str.c_str(), "enable_keep_alive", "yes", "num_threads", thread_pool_buf, - "decode_url", "no", NULL}; + conf_map.erase("port"); + conf_map["listening_ports"] = port_str; + set_conf_default(conf_map, "enable_keep_alive", "yes"); + set_conf_default(conf_map, "num_threads", thread_pool_buf); + set_conf_default(conf_map, "decode_url", "no"); + + const char *options[conf_map.size() * 2 + 1]; + int i = 0; + for (map::iterator iter = conf_map.begin(); iter != conf_map.end(); ++iter) { + options[i] = iter->first.c_str(); + options[i + 1] = iter->second.c_str(); + dout(20)<< "civetweb config: " << options[i] << ": " << (options[i + 1] ? options[i + 1] : "") << dendl; + i += 2; + } + options[i] = NULL; struct mg_callbacks cb; memset((void *)&cb, 0, sizeof(cb));