]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | ||
4 | #include <signal.h> | |
5 | ||
6 | #include "rgw_frontend.h" | |
7 | #include "include/str_list.h" | |
8 | ||
11fdf7f2 | 9 | #include "include/ceph_assert.h" |
7c673cae FG |
10 | |
11 | ||
12 | #define dout_context g_ceph_context | |
13 | #define dout_subsys ceph_subsys_rgw | |
14 | ||
15 | int RGWFrontendConfig::parse_config(const string& config, | |
28e407b8 | 16 | std::multimap<string, string>& config_map) |
7c673cae | 17 | { |
11fdf7f2 | 18 | for (auto& entry : get_str_vec(config, " ")) { |
7c673cae FG |
19 | string key; |
20 | string val; | |
21 | ||
22 | if (framework.empty()) { | |
23 | framework = entry; | |
24 | dout(0) << "framework: " << framework << dendl; | |
25 | continue; | |
26 | } | |
27 | ||
28 | ssize_t pos = entry.find('='); | |
29 | if (pos < 0) { | |
30 | dout(0) << "framework conf key: " << entry << dendl; | |
28e407b8 | 31 | config_map.emplace(std::move(entry), ""); |
7c673cae FG |
32 | continue; |
33 | } | |
34 | ||
35 | int ret = parse_key_value(entry, key, val); | |
36 | if (ret < 0) { | |
37 | cerr << "ERROR: can't parse " << entry << std::endl; | |
38 | return ret; | |
39 | } | |
40 | ||
41 | dout(0) << "framework conf key: " << key << ", val: " << val << dendl; | |
28e407b8 | 42 | config_map.emplace(std::move(key), std::move(val)); |
7c673cae FG |
43 | } |
44 | ||
45 | return 0; | |
46 | } | |
47 | ||
48 | bool RGWFrontendConfig::get_val(const string& key, const string& def_val, | |
49 | string *out) | |
50 | { | |
28e407b8 | 51 | auto iter = config_map.find(key); |
7c673cae FG |
52 | if (iter == config_map.end()) { |
53 | *out = def_val; | |
54 | return false; | |
55 | } | |
56 | ||
57 | *out = iter->second; | |
58 | return true; | |
59 | } | |
60 | ||
61 | bool RGWFrontendConfig::get_val(const string& key, int def_val, int *out) | |
62 | { | |
63 | string str; | |
64 | bool found = get_val(key, "", &str); | |
65 | if (!found) { | |
66 | *out = def_val; | |
67 | return false; | |
68 | } | |
69 | string err; | |
70 | *out = strict_strtol(str.c_str(), 10, &err); | |
71 | if (!err.empty()) { | |
72 | cerr << "error parsing int: " << str << ": " << err << std::endl; | |
73 | return -EINVAL; | |
74 | } | |
75 | return 0; | |
76 | } | |
77 | ||
78 | void RGWProcessFrontend::stop() | |
79 | { | |
80 | pprocess->close_fd(); | |
81 | thread->kill(SIGUSR1); | |
82 | } |