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

Function cdb2_invoke_callback

cdb2api/cdb2api.c:6947–7047  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6945}
6946
6947static void *cdb2_invoke_callback(cdb2_hndl_tp *hndl, cdb2_event *e, int argc,
6948 ...)
6949{
6950 int i;
6951 va_list ap;
6952 void **argv;
6953
6954 const char *hostname;
6955 int port;
6956 const char *sql = NULL;
6957 void *rc;
6958 int state;
6959 char *fp;
6960
6961 /* Fast return if no arguments need to be passed to the callback. */
6962 if (e->argc == 0)
6963 return e->cb(hndl, e->user_arg ? e->user_arg : hndl->user_arg, 0, NULL);
6964
6965 /* Default arguments from the handle. */
6966 if (hndl == NULL) {
6967 hostname = NULL;
6968 port = -1;
6969 } else if (hndl->connected_host < 0) {
6970 if (hndl->cached_host[0] == '\0') {
6971 hostname = NULL;
6972 port = -1;
6973 } else {
6974 hostname = hndl->cached_host;
6975 port = hndl->cached_port;
6976 }
6977 } else {
6978 hostname = hndl->hosts[hndl->connected_host];
6979 port = hndl->ports[hndl->connected_host];
6980 }
6981 rc = 0;
6982 state = 0;
6983
6984 if (hndl->firstresponse == NULL || !hndl->firstresponse->has_fp)
6985 fp = NULL;
6986 else {
6987 fp = alloca(hndl->firstresponse->fp.len * 2 + 1);
6988 stringify_fingerprint(fp, hndl->firstresponse->fp.data, hndl->firstresponse->fp.len);
6989 }
6990
6991 /* If the event has specified its own arguments, use them. */
6992 va_start(ap, argc);
6993 for (i = 0; i < argc; ++i) {
6994 switch (va_arg(ap, cdb2_event_arg)) {
6995 case CDB2_HOSTNAME:
6996 hostname = va_arg(ap, char *);
6997 break;
6998 case CDB2_PORT:
6999 port = va_arg(ap, int);
7000 break;
7001 case CDB2_SQL:
7002 sql = va_arg(ap, char *);
7003 break;
7004 case CDB2_RETURN_VALUE:

Callers 12

cdb2_tcpconnecth_toFunction · 0.85
newsql_connect_via_fdFunction · 0.85
newsql_connectFunction · 0.85
cdb2portmux_getFunction · 0.85
cdb2_read_recordFunction · 0.85
cdb2_send_queryFunction · 0.85
cdb2_next_recordFunction · 0.85
cdb2_closeFunction · 0.85
cdb2_run_statement_typedFunction · 0.85
cdb2_dbinfo_queryFunction · 0.85
cdb2_get_dbhostsFunction · 0.85
cdb2_openFunction · 0.85

Calls 1

stringify_fingerprintFunction · 0.85

Tested by

no test coverage detected