]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: frontend config uses multimap
authorCasey Bodley <cbodley@redhat.com>
Tue, 23 Jan 2018 18:21:11 +0000 (13:21 -0500)
committerCasey Bodley <cbodley@redhat.com>
Fri, 27 Apr 2018 17:00:14 +0000 (13:00 -0400)
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>
(cherry picked from commit cf1b84195ebb8b0abf733889a3fa994a341be1b1)

Conflicts:
        rgw_frontend.cc: missing overload of get_str_vec()

src/rgw/rgw_civetweb_frontend.cc
src/rgw/rgw_frontend.cc
src/rgw/rgw_frontend.h

index 9b405760feb4d99db07b05ff65fbefd36c256ce7..d0d4942943930bd2c71b1490e28938b87c4b9392 100644 (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. */
index a047bcd378019bd8f140b21c5f8851cc1a434c2d..1d61a8fead10269054c2d53c368cb698ca6d73d6 100644 (file)
@@ -13,7 +13,7 @@
 #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);
@@ -33,7 +33,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 +44,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 +53,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;
index 76225e91ab6eafd04d419518fcd338cb66ff96e0..c5d9613536d28c212c1cc28f783748e28d9c9f26 100644 (file)
 
 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);
     }
   }