static void fini_g_conf();
-const char *g_default_id = "admin";
-
static void env_override(char **ceph_var, const char * const env_var)
{
char *e = getenv(env_var);
// fake osd failures: osd -> time
std::map<entity_name_t,float> g_fake_kill_after;
-
md_config_t g_conf;
-bool g_daemon = false;
-
#include <stdlib.h>
#include <string.h>
set_conf_name(opt);
}
+ g_conf.id = strdup("default");
+
return true;
}
std::vector<const char *> nargs;
bool conf_specified = false;
- if (!g_conf.id)
- g_conf.id = (char *)g_default_id;
if (!g_conf.type)
g_conf.type = (char *)"";
g_conf.daemonize = false;
force_foreground_logging = true;
} else if (isdaemon && (CONF_ARG_EQ("id", 'i') || CONF_ARG_EQ("name", 'n'))) {
+ free(g_conf.id);
CONF_SAFE_SET_ARG_VAL(&g_conf.id, OPT_STR);
} else if (!isdaemon && (CONF_ARG_EQ("id", 'I') || CONF_ARG_EQ("name", 'n'))) {
+ free(g_conf.id);
CONF_SAFE_SET_ARG_VAL(&g_conf.id, OPT_STR);
} else {
nargs.push_back(args[i]);
if (module_type) {
g_conf.type = strdup(module_type);
- if (g_conf.id) {
- // is it "type.name"?
- const char *dot = strchr(g_conf.id, '.');
- if (dot) {
- int tlen = dot - g_conf.id;
- g_conf.type = (char *)malloc(tlen + 1);
- memcpy(g_conf.type, g_conf.id, tlen);
- g_conf.type[tlen] = 0;
- g_conf.id = strdup(dot + 1);
- }
-
- int len = strlen(g_conf.type) + strlen(g_conf.id) + 2;
- g_conf.name = (char *)malloc(len);
- snprintf(g_conf.name, len, "%s.%s", g_conf.type, g_conf.id);
- g_conf.alt_name = (char *)malloc(len - 1);
- snprintf(g_conf.alt_name, len - 1, "%s%s", module_type, g_conf.id);
- } else {
- g_conf.name = g_conf.type;
+ // is it "type.name"?
+ const char *dot = strchr(g_conf.id, '.');
+ if (dot) {
+ int tlen = dot - g_conf.id;
+ g_conf.type = (char *)malloc(tlen + 1);
+ memcpy(g_conf.type, g_conf.id, tlen);
+ g_conf.type[tlen] = 0;
+ char *new_g_conf_id = strdup(dot + 1);
+ free(g_conf.id);
+ g_conf.id = new_g_conf_id;
}
+
+ int len = strlen(g_conf.type) + strlen(g_conf.id) + 2;
+ g_conf.name = (char *)malloc(len);
+ snprintf(g_conf.name, len, "%s.%s", g_conf.type, g_conf.id);
+ g_conf.alt_name = (char *)malloc(len - 1);
+ snprintf(g_conf.alt_name, len - 1, "%s%s", module_type, g_conf.id);
}
g_conf.entity_name = new EntityName;
assert(g_conf.entity_name);