* many separate instances.
*/
typedef struct {
-#if PTHREADS
db_list_t *db; /*%< handle to a list of DB */
-#else /* if PTHREADS */
- dbinstance_t *db; /*%< handle to db */
-#endif /* if PTHREADS */
int method; /*%< security authentication
* method */
char *user; /*%< who is authenticating */
return (result);
}
-#if PTHREADS
/*%
* Properly cleans up a list of database instances.
* This function is only used when the driver is compiled for
count);
return (NULL);
}
-#endif /* PTHREADS */
static isc_result_t
dlz_ldap_process_results(ldap_instance_t *db, LDAP *dbc, LDAPMessage *msg,
int entries;
/* get db instance / connection */
-#if PTHREADS
/* find an available DBI from the list */
dbi = dlz_ldap_find_avail_conn(db);
-#else /* PTHREADS */
- /*
- * only 1 DBI - no need to lock instance lock either
- * only 1 thread in the whole process, no possible contention.
- */
- dbi = (dbinstance_t *)(db->db);
-#endif /* PTHREADS */
/* if DBI is null, can't do anything else */
if (dbi == NULL) {
isc_result_t result = ISC_R_FAILURE;
ldap_instance_t *ldap = NULL;
dbinstance_t *dbi = NULL;
- const char *helper_name;
- int protocol;
- int method;
-#if PTHREADS
- int dbcount;
- char *endp;
- int i;
-#endif /* PTHREADS */
+ const char *helper_name = NULL;
+ int protocol, method, dbcount, i;
+ char *endp = NULL;
va_list ap;
UNUSED(dlzname);
}
va_end(ap);
-#if PTHREADS
/* if debugging, let user know we are multithreaded. */
ldap->log(ISC_LOG_DEBUG(1), "LDAP driver running multithreaded");
-#else /* PTHREADS */
- /* if debugging, let user know we are single threaded. */
- ldap->log(ISC_LOG_DEBUG(1), "LDAP driver running single threaded");
-#endif /* PTHREADS */
if (argc < 9) {
ldap->log(ISC_LOG_ERROR, "LDAP driver requires at least "
goto cleanup;
}
- /* multithreaded build can have multiple DB connections */
-#if PTHREADS
/* check how many db connections we should create */
dbcount = strtol(argv[1], &endp, 10);
if (*endp != '\0' || dbcount < 0) {
"must be positive.");
goto cleanup;
}
-#endif /* if PTHREADS */
/* check that LDAP URL parameters make sense */
switch (argc) {
goto cleanup;
}
-#if PTHREADS
/* allocate memory for database connection list */
ldap->db = calloc(1, sizeof(db_list_t));
if (ldap->db == NULL) {
* append each new DBI to the end of the list
*/
for (i = 0; i < dbcount; i++) {
-#endif /* PTHREADS */
/* how many queries were passed in from config file? */
switch (argc) {
case 9:
goto cleanup;
}
-#if PTHREADS
/* when multithreaded, build a list of DBI's */
DLZ_LINK_INIT(dbi, link);
DLZ_LIST_APPEND(*(ldap->db), dbi, link);
-#else /* if PTHREADS */
- /*
- * when single threaded, hold onto the one connection
- * instance.
- */
- ldap->db = dbi;
-#endif /* if PTHREADS */
/* attempt to connect */
result = dlz_ldap_connect(ldap, dbi);
* allocate memory
*/
case ISC_R_NOMEMORY:
-#if PTHREADS
ldap->log(ISC_LOG_ERROR,
"LDAP driver could not allocate memory "
"for connection number %u",
i + 1);
-#else /* if PTHREADS */
- ldap->log(ISC_LOG_ERROR, "LDAP driver could not allocate "
- "memory "
- "for connection");
-#endif /* if PTHREADS */
goto cleanup;
/*
* no perm means ldap_set_option could not set
goto cleanup;
/* failure means couldn't connect to ldap server */
case ISC_R_FAILURE:
-#if PTHREADS
ldap->log(ISC_LOG_ERROR,
"LDAP driver could not bind "
"connection number %u to server.",
i + 1);
-#else /* if PTHREADS */
- ldap->log(ISC_LOG_ERROR, "LDAP driver could not "
- "bind connection to server.");
-#endif /* if PTHREADS */
goto cleanup;
/*
* default should never happen. If it does,
goto cleanup;
}
-#if PTHREADS
/* set DBI = null for next loop through. */
dbi = NULL;
}
-#endif /* PTHREADS */
/* set dbdata to the ldap_instance we created. */
*dbdata = ldap;
dlz_destroy(void *dbdata) {
if (dbdata != NULL) {
ldap_instance_t *db = (ldap_instance_t *)dbdata;
-#if PTHREADS
/* cleanup the list of DBI's */
if (db->db != NULL) {
dlz_ldap_destroy_dblist((db_list_t *)(db->db));
}
-#else /* PTHREADS */
- if (db->db->dbconn != NULL) {
- ldap_unbind_s((LDAP *)(db->db->dbconn));
- }
-
- /* destroy single DB instance */
- destroy_dbinstance(db->db);
-#endif /* PTHREADS */
if (db->hosts != NULL) {
free(db->hosts);
*/
int
dlz_version(unsigned int *flags) {
- *flags |= DNS_SDLZFLAG_RELATIVERDATA;
-#if PTHREADS
- *flags |= DNS_SDLZFLAG_THREADSAFE;
-#else /* if PTHREADS */
- *flags &= ~DNS_SDLZFLAG_THREADSAFE;
-#endif /* if PTHREADS */
+ *flags |= DNS_SDLZFLAG_RELATIVERDATA | DNS_SDLZFLAG_THREADSAFE;
return (DLZ_DLOPEN_VERSION);
}
* many separate instances.
*/
typedef struct {
-#if PTHREADS
db_list_t *db; /*%< handle to a list of DB */
int dbcount;
-#else /* if PTHREADS */
- dbinstance_t *db; /*%< handle to DB */
-#endif /* if PTHREADS */
unsigned int flags;
char *dbname;
destroy_dbinstance(db);
}
-#if PTHREADS
/*%
* Properly cleans up a list of database instances.
* This function is only used when the module is compiled for
count);
return (NULL);
}
-#endif /* PTHREADS */
/*%
* Allocates memory for a new string, and then constructs the new
unsigned int j = 0;
int qres = 0;
-#if PTHREADS
/* find an available DBI from the list */
dbi = mysql_find_avail_conn(db);
-#else /* PTHREADS */
- /*
- * only 1 DBI - no need to lock instance lock either
- * only 1 thread in the whole process, no possible contention.
- */
- dbi = (dbinstance_t *)(db->db);
-#endif /* PTHREADS */
if (dbi == NULL) {
return (ISC_R_FAILURE);
dbinstance_t *dbi = NULL;
MYSQL *dbc;
char *tmp = NULL;
- char *endp;
- int j;
+ char *endp = NULL;
const char *helper_name;
-#if PTHREADS
- int dbcount;
- int i;
-#endif /* PTHREADS */
+ int dbcount, i, j;
va_list ap;
UNUSED(dlzname);
}
va_end(ap);
-#if PTHREADS
/* if debugging, let user know we are multithreaded. */
mysql->log(ISC_LOG_DEBUG(1), "MySQL module running multithreaded");
-#else /* PTHREADS */
- /* if debugging, let user know we are single threaded. */
- mysql->log(ISC_LOG_DEBUG(1), "MySQL module running single threaded");
-#endif /* PTHREADS */
/* verify we have at least 4 arg's passed to the module */
if (argc < 4) {
free(tmp);
}
-#if PTHREADS
/* multithreaded build can have multiple DB connections */
tmp = get_parameter_value(argv[1], "threads=");
if (tmp == NULL) {
* append each new DBI to the end of the list
*/
for (i = 0; i < dbcount; i++) {
-#endif /* PTHREADS */
switch (argc) {
case 4:
result = build_dbinstance(NULL, NULL, NULL, argv[2],
goto cleanup;
}
-#if PTHREADS
/* when multithreaded, build a list of DBI's */
DLZ_LINK_INIT(dbi, link);
DLZ_LIST_APPEND(*(mysql->db), dbi, link);
-#else /* if PTHREADS */
- /*
- * when single threaded, hold onto the one connection
- * instance.
- */
- mysql->db = dbi;
-#endif /* if PTHREADS */
/* create and set db connection */
dbi->dbconn = mysql_init(NULL);
goto cleanup;
}
-#if PTHREADS
/* set DBI = null for next loop through. */
dbi = NULL;
}
-#endif /* PTHREADS */
*dbdata = mysql;
void
dlz_destroy(void *dbdata) {
mysql_instance_t *db = (mysql_instance_t *)dbdata;
-#if PTHREADS
+
/* cleanup the list of DBI's */
if (db->db != NULL) {
mysql_destroy_dblist((db_list_t *)(db->db));
}
-#else /* PTHREADS */
- mysql_destroy(db);
-#endif /* PTHREADS */
if (db->dbname != NULL) {
free(db->dbname);
* many separate instances.
*/
typedef struct {
-#if PTHREADS
db_list_t *db; /*%< handle to a list of DB */
int dbcount;
-#else /* if PTHREADS */
- dbinstance_t *db; /*%< handle to DB */
-#endif /* if PTHREADS */
char *dbname;
destroy_dbinstance(db);
}
-#if PTHREADS
/*%
* Properly cleans up a list of database instances.
* This function is only used when the module is compiled for
count);
return (NULL);
}
-#endif /* PTHREADS */
/*%
* Allocates memory for a new string, and then constructs the new
goto cleanup;
}
-#if PTHREADS
/* find an available DBI from the list */
dbi = sqlite3_find_avail(db);
-#else /* PTHREADS */
- /*
- * only 1 DBI - no need to lock instance lock either
- * only 1 thread in the whole process, no possible contention.
- */
- dbi = (dbinstance_t *)(db->db);
-#endif /* PTHREADS */
if (dbi == NULL) {
return (ISC_R_FAILURE);
dbinstance_t *dbi = NULL;
sqlite3 *dbc = NULL;
char *tmp = NULL;
- char *endp;
+ char *endp = NULL;
const char *helper_name;
-#if PTHREADS
- int dbcount;
- int i, ret;
-#endif /* PTHREADS */
+ int dbcount, i, ret;
va_list ap;
UNUSED(dlzname);
}
va_end(ap);
-#if PTHREADS
/* if debugging, let user know we are multithreaded. */
s3->log(ISC_LOG_DEBUG(1), "SQLite3 module: running multithreaded");
-#else /* PTHREADS */
- /* if debugging, let user know we are single threaded. */
- s3->log(ISC_LOG_DEBUG(1), "SQLite3 module: running single threaded");
-#endif /* PTHREADS */
/* verify we have at least 4 arg's passed to the module */
if (argc < 4) {
goto cleanup;
}
-#if PTHREADS
/* multithreaded build can have multiple DB connections */
tmp = get_parameter_value(argv[1], "threads=");
if (tmp == NULL) {
* append each new DBI to the end of the list
*/
for (i = 0; i < dbcount; i++) {
-#endif /* PTHREADS */
switch (argc) {
case 4:
result = build_dbinstance(NULL, NULL, NULL, argv[2],
goto cleanup;
}
-#if PTHREADS
/* when multithreaded, build a list of DBI's */
DLZ_LINK_INIT(dbi, link);
DLZ_LIST_APPEND(*(s3->db), dbi, link);
-#else /* if PTHREADS */
- /*
- * when single threaded, hold onto the one connection
- * instance.
- */
- s3->db = dbi;
-#endif /* if PTHREADS */
dbi->dbconn = dbc;
dbc = NULL;
-#if PTHREADS
/* set DBI = null for next loop through. */
dbi = NULL;
}
-#endif /* PTHREADS */
*dbdata = s3;
return (ISC_R_SUCCESS);
void
dlz_destroy(void *dbdata) {
sqlite3_instance_t *db = (sqlite3_instance_t *)dbdata;
-#if PTHREADS
/* cleanup the list of DBI's */
if (db->db != NULL) {
sqlite3_destroy_dblist((db_list_t *)(db->db));
}
-#else /* PTHREADS */
- sqlite3_destroy(db);
-#endif /* PTHREADS */
if (db->dbname != NULL) {
free(db->dbname);