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

Function cdb2_open

cdb2api/cdb2api.c:6579–6743  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6577int comdb2_cheapstack_char_array(char *str, int maxln);
6578
6579int cdb2_open(cdb2_hndl_tp **handle, const char *dbname, const char *type,
6580 int flags)
6581{
6582 cdb2_hndl_tp *hndl;
6583 int rc = 0;
6584 void *callbackrc;
6585 cdb2_event *e = NULL;
6586
6587 pthread_mutex_lock(&cdb2_cfg_lock);
6588 pthread_once(&init_once, do_init_once);
6589 pthread_mutex_unlock(&cdb2_cfg_lock);
6590
6591 *handle = hndl = calloc(1, sizeof(cdb2_hndl_tp));
6592 hndl->events = calloc(1, sizeof(*hndl->events));
6593 hndl->gbl_event_version = calloc(1, sizeof(*hndl->gbl_event_version));
6594 strncpy(hndl->dbname, dbname, sizeof(hndl->dbname) - 1);
6595 strncpy(hndl->cluster, type, sizeof(hndl->cluster) - 1);
6596 strncpy(hndl->type, type, sizeof(hndl->type) - 1);
6597 hndl->flags = flags;
6598 hndl->dbnum = 1;
6599 hndl->connected_host = -1;
6600 hndl->send_stack = 0;
6601 hndl->read_intrans_results = 1;
6602
6603 /* We don't do dbinfo if DIRECT_CPU. So we'd default peer SSL mode to
6604 ALLOW. We will find it out later when we send SSL negotitaion packet
6605 to the server. */
6606 hndl->s_sslmode = PEER_SSL_ALLOW;
6607
6608 hndl->max_retries = MAX_RETRIES;
6609 hndl->min_retries = MIN_RETRIES;
6610
6611 hndl->env_tz = getenv("COMDB2TZ");
6612 hndl->is_admin = (flags & CDB2_ADMIN);
6613
6614 if (hndl->env_tz == NULL)
6615 hndl->env_tz = getenv("TZ");
6616
6617 if (hndl->env_tz == NULL)
6618 hndl->env_tz = DB_TZNAME_DEFAULT;
6619
6620
6621 cdb2_init_context_msgs(hndl);
6622
6623 if (getenv("CDB2_DEBUG")) {
6624 hndl->debug_trace = 1;
6625 debugprint("debug trace enabled\n");
6626 }
6627
6628 if (hndl->flags & CDB2_RANDOM) {
6629 strcpy(hndl->policy, "random");
6630 } else if (hndl->flags & CDB2_RANDOMROOM) {
6631 strcpy(hndl->policy, "random_room");
6632 } else if (hndl->flags & CDB2_ROOM) {
6633 strcpy(hndl->policy, "room");
6634 } else {
6635 hndl->flags |= CDB2_RANDOMROOM;
6636 /* DIRECTCPU mode behaves like RANDOMROOM. But let's pick a shorter policy name

Callers 15

db_generatorFunction · 0.85
run_statementFunction · 0.85
send_cancel_cnonceFunction · 0.85
comdb2_storeMethod · 0.85
process_eventsFunction · 0.85
mainFunction · 0.85
insert_records_thdFunction · 0.85
update_records_thdFunction · 0.85
mainFunction · 0.85
record_countFunction · 0.85
select_and_update_orphanFunction · 0.85

Calls 13

callocFunction · 0.85
cdb2_init_context_msgsFunction · 0.85
only_read_configFunction · 0.85
is_machine_listFunction · 0.85
configure_from_literalFunction · 0.85
cdb2_get_dbhostsFunction · 0.85
set_up_ssl_paramsFunction · 0.85
process_set_commandFunction · 0.85
cdb2_next_callbackFunction · 0.85
cdb2_invoke_callbackFunction · 0.85

Tested by 8

masterFunction · 0.68
mainFunction · 0.68
updaterFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68
test_openFunction · 0.68
run_statementFunction · 0.68
mainFunction · 0.68