Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cdb2api/cdb2_identity.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
#ifndef INCLUDED_CDB2_IDENTITY_H
#define INCLUDED_CDB2_IDENTITY_H

#ifdef __cplusplus
extern "C" {
#endif

enum cdb2_identity_flags { CDB2_USE_OPTIONAL_IDENTITY = 1, CDB2_NON_THREADED_IDENTITY = 1 << 1 };

#ifdef __cplusplus
}
#endif
#endif
53 changes: 37 additions & 16 deletions cdb2api/cdb2api.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,11 @@ static int local_connection_cache_check_pid_envvar = 0;

static int connection_cache_entries = 0;

#ifdef CDB2API_AMALGAMATION
static int cdb2_use_ftruncate = 0;
#else
int cdb2_use_ftruncate = 0;
#endif
static int cdb2_use_ftruncate_set_from_env = 0;
static int cdb2_use_env_vars = 1;
static int cdb2_install_set_from_env = 0;
Expand All @@ -250,8 +254,8 @@ TAILQ_HEAD(local_connection_cache_list, local_cached_connection);

/* owner of the in-proc connection cache */
static pid_t local_connection_cache_owner_pid;
struct local_connection_cache_list local_connection_cache;
struct local_connection_cache_list free_local_connection_cache;
static struct local_connection_cache_list local_connection_cache;
static struct local_connection_cache_list free_local_connection_cache;
typedef struct local_connection_cache_list local_connection_cache_list;

static int cdb2cfg_override = 0;
Expand Down Expand Up @@ -490,21 +494,30 @@ extern void CDB2_UNINSTALL_LIBS(const char *);
#endif
void (*cdb2_uninstall)(const char *) = CDB2_UNINSTALL_LIBS;

#ifndef CDB2_IDENTITY_CALLBACKS
struct cdb2_identity *identity_cb = NULL;
#ifdef CDB2API_SERVER // identity_cb is non-static, because simpleauth needs to set it
# ifdef CDB2_IDENTITY_CALLBACKS
extern struct cdb2_identity CDB2_IDENTITY_CALLBACKS;
struct cdb2_identity *identity_cb = &CDB2_IDENTITY_CALLBACKS;
# else
struct cdb2_identity *identity_cb = NULL;
# endif
#else
extern struct cdb2_identity CDB2_IDENTITY_CALLBACKS;
struct cdb2_identity *identity_cb = &CDB2_IDENTITY_CALLBACKS;
# ifdef CDB2_IDENTITY_CALLBACKS
extern struct cdb2_identity CDB2_IDENTITY_CALLBACKS;
static struct cdb2_identity *identity_cb = &CDB2_IDENTITY_CALLBACKS;
# else
static struct cdb2_identity *identity_cb = NULL;
# endif
#endif

#ifndef CDB2_PUBLISH_EVENT_CALLBACKS
struct cdb2_publish_event *publish_event_cb = NULL;
#else
#if defined(CDB2API_SERVER) || !defined(CDB2_PUBLISH_EVENT_CALLBACKS) || !defined(CDB2API_TEST)
static struct cdb2_publish_event *publish_event_cb = NULL;
#elif defined(CDB2_PUBLISH_EVENT_CALLBACKS)
extern struct cdb2_publish_event CDB2_PUBLISH_EVENT_CALLBACKS;
struct cdb2_publish_event *publish_event_cb = &CDB2_PUBLISH_EVENT_CALLBACKS;
static struct cdb2_publish_event *publish_event_cb = &CDB2_PUBLISH_EVENT_CALLBACKS;
#endif

pthread_mutex_t cdb2_sockpool_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t cdb2_sockpool_mutex = PTHREAD_MUTEX_INITIALIZER;
#define MAX_SOCKPOOL_FDS 8

#include <netdb.h>
Expand Down Expand Up @@ -9135,13 +9148,12 @@ int cdb2_open(cdb2_hndl_tp **handle, const char *dbname, const char *type,
return rc;
}

cdb2_event *cdb2_register_event(cdb2_hndl_tp *hndl, cdb2_event_type types,
static cdb2_event *cdb2_register_event_varg(cdb2_hndl_tp *hndl, cdb2_event_type types,
cdb2_event_ctrl ctrls, cdb2_event_callback cb,
void *user_arg, int nargs, ...)
void *user_arg, int nargs, va_list ap)
{
cdb2_event *ret;
cdb2_event *curr;
va_list ap;
int i;

/* Allocate an event object. */
Expand All @@ -9157,10 +9169,8 @@ cdb2_event *cdb2_register_event(cdb2_hndl_tp *hndl, cdb2_event_type types,
ret->argc = nargs;

/* Copy over argument types. */
va_start(ap, nargs);
for (i = 0; i != nargs; ++i)
ret->argv[i] = va_arg(ap, cdb2_event_arg);
va_end(ap);

if (hndl == NULL) {
/* handle is NULL. We want to register to the global events. */
Expand All @@ -9181,6 +9191,17 @@ cdb2_event *cdb2_register_event(cdb2_hndl_tp *hndl, cdb2_event_type types,
return ret;
}

cdb2_event *cdb2_register_event(cdb2_hndl_tp *hndl, cdb2_event_type types,
cdb2_event_ctrl ctrls, cdb2_event_callback cb,
void *user_arg, int nargs, ...)
{
va_list ap;
va_start(ap, nargs);
cdb2_event *ret = cdb2_register_event_varg(hndl, types, ctrls, cb, user_arg, nargs, ap);
va_end(ap);
return ret;
}

int cdb2_unregister_event(cdb2_hndl_tp *hndl, cdb2_event *event)
{
cdb2_event *curr, *prev;
Expand Down
10 changes: 10 additions & 0 deletions cdb2api/cdb2api_hndl.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@

#ifndef INCLUDED_CDB2API_HNDL_H
#define INCLUDED_CDB2API_HNDL_H

#ifdef __cplusplus
extern "C" {
#endif

#include <comdb2buf.h>

#include <sys/types.h>
Expand Down Expand Up @@ -209,4 +214,9 @@ struct cdb2_hndl {
RETRY_CALLBACK retry_clbk;
int is_tagged;
};

#ifdef __cplusplus
}
#endif

#endif
2 changes: 2 additions & 0 deletions util/comdb2buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -948,4 +948,6 @@ int CDB2BUF_FUNC(cdb2buf_lasterror)(COMDB2BUF *sb, char *err, size_t n)
return sb->protocolerr;
}

#ifndef CDB2API_AMALGAMATION
#include "ssl_io.c"
#endif
Loading