diff --git a/contrib/dlz/modules/ldap/dlz_ldap_dynamic.c b/contrib/dlz/modules/ldap/dlz_ldap_dynamic.c index 7f9231244a..48f4b63262 100644 --- a/contrib/dlz/modules/ldap/dlz_ldap_dynamic.c +++ b/contrib/dlz/modules/ldap/dlz_ldap_dynamic.c @@ -69,11 +69,7 @@ * 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 */ @@ -227,7 +223,6 @@ cleanup: return (result); } -#if PTHREADS /*% * Properly cleans up a list of database instances. * This function is only used when the driver is compiled for @@ -298,7 +293,6 @@ dlz_ldap_find_avail_conn(ldap_instance_t *ldap) { count); return (NULL); } -#endif /* PTHREADS */ static isc_result_t dlz_ldap_process_results(ldap_instance_t *db, LDAP *dbc, LDAPMessage *msg, @@ -542,16 +536,8 @@ dlz_ldap_get_results(const char *zone, const char *record, const char *client, 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) { @@ -904,14 +890,9 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata, 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); @@ -930,13 +911,8 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata, } 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 " @@ -978,8 +954,6 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata, 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) { @@ -988,7 +962,6 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata, "must be positive."); goto cleanup; } -#endif /* if PTHREADS */ /* check that LDAP URL parameters make sense */ switch (argc) { @@ -1045,7 +1018,6 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata, goto cleanup; } -#if PTHREADS /* allocate memory for database connection list */ ldap->db = calloc(1, sizeof(db_list_t)); if (ldap->db == NULL) { @@ -1061,7 +1033,6 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata, * 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: @@ -1099,17 +1070,9 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata, 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); @@ -1126,16 +1089,10 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata, * 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 @@ -1148,15 +1105,10 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata, 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, @@ -1169,11 +1121,9 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata, 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; @@ -1190,19 +1140,10 @@ void 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); @@ -1222,12 +1163,7 @@ dlz_destroy(void *dbdata) { */ 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); } diff --git a/contrib/dlz/modules/mysql/dlz_mysql_dynamic.c b/contrib/dlz/modules/mysql/dlz_mysql_dynamic.c index 81b46aa79e..d56895d10c 100644 --- a/contrib/dlz/modules/mysql/dlz_mysql_dynamic.c +++ b/contrib/dlz/modules/mysql/dlz_mysql_dynamic.c @@ -64,12 +64,8 @@ typedef bool my_bool; * 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; @@ -112,7 +108,6 @@ mysql_destroy(dbinstance_t *db) { destroy_dbinstance(db); } -#if PTHREADS /*% * Properly cleans up a list of database instances. * This function is only used when the module is compiled for @@ -175,7 +170,6 @@ mysql_find_avail_conn(mysql_instance_t *mysql) { count); return (NULL); } -#endif /* PTHREADS */ /*% * Allocates memory for a new string, and then constructs the new @@ -224,16 +218,8 @@ mysql_get_resultset(const char *zone, const char *record, const char *client, 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); @@ -798,13 +784,9 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata, 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); @@ -823,13 +805,8 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata, } 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) { @@ -901,7 +878,6 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata, free(tmp); } -#if PTHREADS /* multithreaded build can have multiple DB connections */ tmp = get_parameter_value(argv[1], "threads="); if (tmp == NULL) { @@ -934,7 +910,6 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata, * 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], @@ -973,17 +948,9 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata, 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); @@ -1029,11 +996,9 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata, goto cleanup; } -#if PTHREADS /* set DBI = null for next loop through. */ dbi = NULL; } -#endif /* PTHREADS */ *dbdata = mysql; @@ -1051,14 +1016,11 @@ cleanup: 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); diff --git a/contrib/dlz/modules/sqlite3/dlz_sqlite3_dynamic.c b/contrib/dlz/modules/sqlite3/dlz_sqlite3_dynamic.c index c2a8958d6a..70358b329e 100644 --- a/contrib/dlz/modules/sqlite3/dlz_sqlite3_dynamic.c +++ b/contrib/dlz/modules/sqlite3/dlz_sqlite3_dynamic.c @@ -59,12 +59,8 @@ * 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; @@ -113,7 +109,6 @@ sqlite3_destroy(dbinstance_t *db) { destroy_dbinstance(db); } -#if PTHREADS /*% * Properly cleans up a list of database instances. * This function is only used when the module is compiled for @@ -176,7 +171,6 @@ sqlite3_find_avail(sqlite3_instance_t *sqlite3) { count); return (NULL); } -#endif /* PTHREADS */ /*% * Allocates memory for a new string, and then constructs the new @@ -252,16 +246,8 @@ sqlite3_get_resultset(const char *zone, const char *record, const char *client, 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); @@ -870,12 +856,9 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata, 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); @@ -894,13 +877,8 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata, } 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) { @@ -925,7 +903,6 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata, goto cleanup; } -#if PTHREADS /* multithreaded build can have multiple DB connections */ tmp = get_parameter_value(argv[1], "threads="); if (tmp == NULL) { @@ -958,7 +935,6 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata, * 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], @@ -1014,25 +990,15 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata, 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); @@ -1049,14 +1015,10 @@ cleanup: 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);