return string(buf);
}
-static list<string> hostnames_list;
+/* avoid duplicate hostnames in hostnames list */
+static set<string> hostnames_set;
void rgw_rest_init(CephContext *cct, RGWRegion& region)
{
http_status_names[h->code] = h->name;
}
- /* avoid duplicate hostnames in hostnames list */
- map<string, bool> hostnames_map;
if (!cct->_conf->rgw_dns_name.empty()) {
- hostnames_map[cct->_conf->rgw_dns_name] = true;
- }
- for (list<string>::iterator iter = region.hostnames.begin(); iter != region.hostnames.end(); ++iter) {
- hostnames_map[*iter] = true;
- }
-
- for (map<string, bool>::iterator iter = hostnames_map.begin(); iter != hostnames_map.end(); ++iter) {
- hostnames_list.push_back(iter->first);
+ hostnames_set.insert(cct->_conf->rgw_dns_name);
}
+ hostnames_set.insert(region.hostnames.begin(), region.hostnames.end());
}
static bool str_ends_with(const string& s, const string& suffix, size_t *pos)
static bool rgw_find_host_in_domains(const string& host, string *domain, string *subdomain)
{
- list<string>::iterator iter;
- for (iter = hostnames_list.begin(); iter != hostnames_list.end(); ++iter) {
+ set<string>::iterator iter;
+ for (iter = hostnames_set.begin(); iter != hostnames_set.end(); ++iter) {
size_t pos;
if (!str_ends_with(host, *iter, &pos))
continue;