MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / read_comdb2db_cfg

Function read_comdb2db_cfg

cdb2api/cdb2api.c:1310–1560  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1308static void only_read_config(cdb2_hndl_tp *, int, int); /* FORWARD */
1309
1310static void read_comdb2db_cfg(cdb2_hndl_tp *hndl, SBUF2 *s, const char *comdb2db_name, const char *buf,
1311 char comdb2db_hosts[][CDB2HOSTNAME_LEN], int *num_hosts, int *comdb2db_num,
1312 const char *dbname, char db_hosts[][CDB2HOSTNAME_LEN], int *num_db_hosts, int *dbnum,
1313 int *stack_at_open)
1314{
1315 char line[PATH_MAX > 2048 ? PATH_MAX : 2048] = {0};
1316 int line_no = 0;
1317
1318 debugprint("entering\n");
1319 while (read_line((char *)&line, sizeof(line), s, buf, &line_no) != -1) {
1320 char *last = NULL;
1321 char *tok = NULL;
1322 tok = strtok_r(line, " :", &last);
1323 if (tok == NULL)
1324 continue;
1325 else if (comdb2db_name && strcasecmp(comdb2db_name, tok) == 0) {
1326 tok = strtok_r(NULL, " :,", &last);
1327 if (tok && is_valid_int(tok)) {
1328 *comdb2db_num = atoi(tok);
1329 tok = strtok_r(NULL, " :,", &last);
1330 }
1331 while (tok != NULL) {
1332 strncpy(comdb2db_hosts[*num_hosts], tok, CDB2HOSTNAME_LEN - 1);
1333 (*num_hosts)++;
1334 tok = strtok_r(NULL, " :,", &last);
1335 }
1336 } else if (dbname && (strcasecmp(dbname, tok) == 0)) {
1337 tok = strtok_r(NULL, " :,", &last);
1338 if (tok && is_valid_int(tok)) {
1339 *dbnum = atoi(tok);
1340 tok = strtok_r(NULL, " :,", &last);
1341 }
1342 while (tok != NULL) {
1343 strncpy(db_hosts[*num_db_hosts], tok, CDB2HOSTNAME_LEN - 1);
1344 tok = strtok_r(NULL, " :,", &last);
1345 (*num_db_hosts)++;
1346 }
1347 } else if (strcasecmp("comdb2_feature", tok) == 0) {
1348 tok = strtok_r(NULL, " =:,", &last);
1349 if ((strcasecmp("iam_identity_v6",tok) == 0)) {
1350 tok = strtok_r(NULL, " =:,", &last);
1351 if (tok)
1352 iam_identity = value_on_off(tok);
1353 }
1354 } else if (strcasecmp("comdb2_config", tok) == 0) {
1355 tok = strtok_r(NULL, " =:,", &last);
1356 if (tok == NULL) continue;
1357 pthread_mutex_lock(&cdb2_sockpool_mutex);
1358 if (strcasecmp("default_type", tok) == 0) {
1359 tok = strtok_r(NULL, " :,", &last);
1360 if (tok) {
1361 if (hndl && (strcasecmp(hndl->cluster, "default") == 0)) {
1362 strncpy(hndl->cluster, tok, sizeof(cdb2_default_cluster) - 1);
1363 } else if (!hndl) {
1364 strncpy(cdb2_default_cluster, tok, sizeof(cdb2_default_cluster) - 1);
1365 }
1366 }
1367 } else if (strcasecmp("room", tok) == 0) {

Callers 2

test_read_comdb2db_cfgFunction · 0.85

Calls 3

is_valid_intFunction · 0.85
only_read_configFunction · 0.85
read_lineFunction · 0.70

Tested by 1

test_read_comdb2db_cfgFunction · 0.68