rgw: frontend config uses multimap

this allows us to configure multiple values for a given key without
resorting to string formatting to cram them into a single key/value pair

ex. port=80 port=443s instead of port=80+443s

Signed-off-by: Casey Bodley <cbodley@redhat.com>
This commit is contained in:
Casey Bodley 2018-01-23 13:21:11 -05:00
parent 9cdd2fe658
commit cf1b84195e
3 changed files with 12 additions and 17 deletions

View File

@ -61,13 +61,13 @@ int RGWCivetWebFrontend::run()
set_conf_default(conf_map, "enable_auth_domain_check", "no");
conf->get_val("port", "80", &port_str);
std::replace(port_str.begin(), port_str.end(), '+', ',');
conf_map["listening_ports"] = port_str;
conf_map.emplace("listening_ports", std::move(port_str));
/* Set run_as_user. This will cause civetweb to invoke setuid() and setgid()
* based on pw_uid and pw_gid obtained from pw_name. */
std::string uid_string = g_ceph_context->get_set_uid_string();
if (! uid_string.empty()) {
conf_map["run_as_user"] = std::move(uid_string);
conf_map.emplace("run_as_user", std::move(uid_string));
}
/* Prepare options for CivetWeb. */

View File

@ -13,14 +13,9 @@
#define dout_subsys ceph_subsys_rgw
int RGWFrontendConfig::parse_config(const string& config,
map<string, string>& config_map)
std::multimap<string, string>& config_map)
{
list<string> config_list;
get_str_list(config, " ", config_list);
list<string>::iterator iter;
for (iter = config_list.begin(); iter != config_list.end(); ++iter) {
string& entry = *iter;
for (auto& entry : get_str_vec(config, " ")) {
string key;
string val;
@ -33,7 +28,7 @@ int RGWFrontendConfig::parse_config(const string& config,
ssize_t pos = entry.find('=');
if (pos < 0) {
dout(0) << "framework conf key: " << entry << dendl;
config_map[entry] = "";
config_map.emplace(std::move(entry), "");
continue;
}
@ -44,7 +39,7 @@ int RGWFrontendConfig::parse_config(const string& config,
}
dout(0) << "framework conf key: " << key << ", val: " << val << dendl;
config_map[key] = val;
config_map.emplace(std::move(key), std::move(val));
}
return 0;
@ -53,7 +48,7 @@ int RGWFrontendConfig::parse_config(const string& config,
bool RGWFrontendConfig::get_val(const string& key, const string& def_val,
string *out)
{
map<string, string>::iterator iter = config_map.find(key);
auto iter = config_map.find(key);
if (iter == config_map.end()) {
*out = def_val;
return false;

View File

@ -22,11 +22,11 @@
class RGWFrontendConfig {
std::string config;
std::map<std::string, std::string> config_map;
std::multimap<std::string, std::string> config_map;
std::string framework;
int parse_config(const std::string& config,
std::map<std::string, std::string>& config_map);
std::multimap<std::string, std::string>& config_map);
public:
RGWFrontendConfig(const std::string& config)
@ -54,7 +54,7 @@ public:
return config;
}
std::map<std::string, std::string>& get_config_map() {
std::multimap<std::string, std::string>& get_config_map() {
return config_map;
}
@ -97,11 +97,11 @@ class RGWCivetWebFrontend : public RGWFrontend {
struct mg_context* ctx;
RGWMongooseEnv env;
void set_conf_default(std::map<std::string, std::string>& m,
void set_conf_default(std::multimap<std::string, std::string>& m,
const std::string& key,
const std::string& def_val) {
if (m.find(key) == std::end(m)) {
m[key] = def_val;
m.emplace(key, def_val);
}
}