c0565f
From 053886b260204e399a33a6b95c6ee95f6161b451 Mon Sep 17 00:00:00 2001
c0565f
From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= <pemensik@redhat.com>
c0565f
Date: Fri, 21 Jan 2022 18:52:45 +0100
c0565f
Subject: [PATCH] Remove remains of #if PTHREADS
c0565f
c0565f
Always use only threaded version. Single thread version does not exist
c0565f
anymore.
c0565f
---
c0565f
 contrib/dlz/modules/ldap/dlz_ldap_dynamic.c   | 59 -------------------
c0565f
 contrib/dlz/modules/mysql/dlz_mysql_dynamic.c | 37 ------------
c0565f
 .../dlz/modules/sqlite3/dlz_sqlite3_dynamic.c | 37 ------------
c0565f
 3 files changed, 133 deletions(-)
c0565f
c0565f
diff --git a/contrib/dlz/modules/ldap/dlz_ldap_dynamic.c b/contrib/dlz/modules/ldap/dlz_ldap_dynamic.c
c0565f
index 7f9231244a..25a7837b67 100644
c0565f
--- a/contrib/dlz/modules/ldap/dlz_ldap_dynamic.c
c0565f
+++ b/contrib/dlz/modules/ldap/dlz_ldap_dynamic.c
c0565f
@@ -69,11 +69,7 @@
c0565f
  * many separate instances.
c0565f
  */
c0565f
 typedef struct {
c0565f
-#if PTHREADS
c0565f
 	db_list_t *db; /*%< handle to a list of DB */
c0565f
-#else		       /* if PTHREADS */
c0565f
-	dbinstance_t *db; /*%< handle to db */
c0565f
-#endif		       /* if PTHREADS */
c0565f
 	int method;    /*%< security authentication
c0565f
 			* method */
c0565f
 	char *user;    /*%< who is authenticating */
c0565f
@@ -227,7 +223,6 @@ cleanup:
c0565f
 	return (result);
c0565f
 }
c0565f
 
c0565f
-#if PTHREADS
c0565f
 /*%
c0565f
  * Properly cleans up a list of database instances.
c0565f
  * This function is only used when the driver is compiled for
c0565f
@@ -298,7 +293,6 @@ dlz_ldap_find_avail_conn(ldap_instance_t *ldap) {
c0565f
 		  count);
c0565f
 	return (NULL);
c0565f
 }
c0565f
-#endif /* PTHREADS */
c0565f
 
c0565f
 static isc_result_t
c0565f
 dlz_ldap_process_results(ldap_instance_t *db, LDAP *dbc, LDAPMessage *msg,
c0565f
@@ -542,16 +536,8 @@ dlz_ldap_get_results(const char *zone, const char *record, const char *client,
c0565f
 	int entries;
c0565f
 
c0565f
 	/* get db instance / connection */
c0565f
-#if PTHREADS
c0565f
 	/* find an available DBI from the list */
c0565f
 	dbi = dlz_ldap_find_avail_conn(db);
c0565f
-#else  /* PTHREADS */
c0565f
-	/*
c0565f
-	 * only 1 DBI - no need to lock instance lock either
c0565f
-	 * only 1 thread in the whole process, no possible contention.
c0565f
-	 */
c0565f
-	dbi = (dbinstance_t *)(db->db);
c0565f
-#endif /* PTHREADS */
c0565f
 
c0565f
 	/* if DBI is null, can't do anything else */
c0565f
 	if (dbi == NULL) {
c0565f
@@ -907,11 +893,9 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata,
c0565f
 	const char *helper_name;
c0565f
 	int protocol;
c0565f
 	int method;
c0565f
-#if PTHREADS
c0565f
 	int dbcount;
c0565f
 	char *endp;
c0565f
 	int i;
c0565f
-#endif /* PTHREADS */
c0565f
 	va_list ap;
c0565f
 
c0565f
 	UNUSED(dlzname);
c0565f
@@ -930,13 +914,8 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata,
c0565f
 	}
c0565f
 	va_end(ap);
c0565f
 
c0565f
-#if PTHREADS
c0565f
 	/* if debugging, let user know we are multithreaded. */
c0565f
 	ldap->log(ISC_LOG_DEBUG(1), "LDAP driver running multithreaded");
c0565f
-#else  /* PTHREADS */
c0565f
-	/* if debugging, let user know we are single threaded. */
c0565f
-	ldap->log(ISC_LOG_DEBUG(1), "LDAP driver running single threaded");
c0565f
-#endif /* PTHREADS */
c0565f
 
c0565f
 	if (argc < 9) {
c0565f
 		ldap->log(ISC_LOG_ERROR, "LDAP driver requires at least "
c0565f
@@ -979,7 +958,6 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata,
c0565f
 	}
c0565f
 
c0565f
 	/* multithreaded build can have multiple DB connections */
c0565f
-#if PTHREADS
c0565f
 	/* check how many db connections we should create */
c0565f
 	dbcount = strtol(argv[1], &endp, 10);
c0565f
 	if (*endp != '\0' || dbcount < 0) {
c0565f
@@ -988,7 +966,6 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata,
c0565f
 					 "must be positive.");
c0565f
 		goto cleanup;
c0565f
 	}
c0565f
-#endif /* if PTHREADS */
c0565f
 
c0565f
 	/* check that LDAP URL parameters make sense */
c0565f
 	switch (argc) {
c0565f
@@ -1045,7 +1022,6 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata,
c0565f
 		goto cleanup;
c0565f
 	}
c0565f
 
c0565f
-#if PTHREADS
c0565f
 	/* allocate memory for database connection list */
c0565f
 	ldap->db = calloc(1, sizeof(db_list_t));
c0565f
 	if (ldap->db == NULL) {
c0565f
@@ -1061,7 +1037,6 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata,
c0565f
 	 * append each new DBI to the end of the list
c0565f
 	 */
c0565f
 	for (i = 0; i < dbcount; i++) {
c0565f
-#endif /* PTHREADS */
c0565f
 		/* how many queries were passed in from config file? */
c0565f
 		switch (argc) {
c0565f
 		case 9:
c0565f
@@ -1099,17 +1074,9 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata,
c0565f
 			goto cleanup;
c0565f
 		}
c0565f
 
c0565f
-#if PTHREADS
c0565f
 		/* when multithreaded, build a list of DBI's */
c0565f
 		DLZ_LINK_INIT(dbi, link);
c0565f
 		DLZ_LIST_APPEND(*(ldap->db), dbi, link);
c0565f
-#else  /* if PTHREADS */
c0565f
-	/*
c0565f
-	 * when single threaded, hold onto the one connection
c0565f
-	 * instance.
c0565f
-	 */
c0565f
-	ldap->db = dbi;
c0565f
-#endif /* if PTHREADS */
c0565f
 		/* attempt to connect */
c0565f
 		result = dlz_ldap_connect(ldap, dbi);
c0565f
 
c0565f
@@ -1126,16 +1093,10 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata,
c0565f
 		 * allocate memory
c0565f
 		 */
c0565f
 		case ISC_R_NOMEMORY:
c0565f
-#if PTHREADS
c0565f
 			ldap->log(ISC_LOG_ERROR,
c0565f
 				  "LDAP driver could not allocate memory "
c0565f
 				  "for connection number %u",
c0565f
 				  i + 1);
c0565f
-#else  /* if PTHREADS */
c0565f
-		ldap->log(ISC_LOG_ERROR, "LDAP driver could not allocate "
c0565f
-					 "memory "
c0565f
-					 "for connection");
c0565f
-#endif /* if PTHREADS */
c0565f
 			goto cleanup;
c0565f
 		/*
c0565f
 		 * no perm means ldap_set_option could not set
c0565f
@@ -1148,15 +1109,10 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata,
c0565f
 			goto cleanup;
c0565f
 		/* failure means couldn't connect to ldap server */
c0565f
 		case ISC_R_FAILURE:
c0565f
-#if PTHREADS
c0565f
 			ldap->log(ISC_LOG_ERROR,
c0565f
 				  "LDAP driver could not bind "
c0565f
 				  "connection number %u to server.",
c0565f
 				  i + 1);
c0565f
-#else  /* if PTHREADS */
c0565f
-		ldap->log(ISC_LOG_ERROR, "LDAP driver could not "
c0565f
-					 "bind connection to server.");
c0565f
-#endif /* if PTHREADS */
c0565f
 			goto cleanup;
c0565f
 		/*
c0565f
 		 * default should never happen.  If it does,
c0565f
@@ -1169,11 +1125,9 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata,
c0565f
 			goto cleanup;
c0565f
 		}
c0565f
 
c0565f
-#if PTHREADS
c0565f
 		/* set DBI = null for next loop through. */
c0565f
 		dbi = NULL;
c0565f
 	}
c0565f
-#endif /* PTHREADS */
c0565f
 
c0565f
 	/* set dbdata to the ldap_instance we created. */
c0565f
 	*dbdata = ldap;
c0565f
@@ -1190,19 +1144,10 @@ void
c0565f
 dlz_destroy(void *dbdata) {
c0565f
 	if (dbdata != NULL) {
c0565f
 		ldap_instance_t *db = (ldap_instance_t *)dbdata;
c0565f
-#if PTHREADS
c0565f
 		/* cleanup the list of DBI's */
c0565f
 		if (db->db != NULL) {
c0565f
 			dlz_ldap_destroy_dblist((db_list_t *)(db->db));
c0565f
 		}
c0565f
-#else  /* PTHREADS */
c0565f
-		if (db->db->dbconn != NULL) {
c0565f
-			ldap_unbind_s((LDAP *)(db->db->dbconn));
c0565f
-		}
c0565f
-
c0565f
-		/* destroy single DB instance */
c0565f
-		destroy_dbinstance(db->db);
c0565f
-#endif /* PTHREADS */
c0565f
 
c0565f
 		if (db->hosts != NULL) {
c0565f
 			free(db->hosts);
c0565f
@@ -1223,11 +1168,7 @@ dlz_destroy(void *dbdata) {
c0565f
 int
c0565f
 dlz_version(unsigned int *flags) {
c0565f
 	*flags |= DNS_SDLZFLAG_RELATIVERDATA;
c0565f
-#if PTHREADS
c0565f
 	*flags |= DNS_SDLZFLAG_THREADSAFE;
c0565f
-#else  /* if PTHREADS */
c0565f
-	*flags &= ~DNS_SDLZFLAG_THREADSAFE;
c0565f
-#endif /* if PTHREADS */
c0565f
 	return (DLZ_DLOPEN_VERSION);
c0565f
 }
c0565f
 
c0565f
diff --git a/contrib/dlz/modules/mysql/dlz_mysql_dynamic.c b/contrib/dlz/modules/mysql/dlz_mysql_dynamic.c
c0565f
index 81b46aa79e..0b8be40112 100644
c0565f
--- a/contrib/dlz/modules/mysql/dlz_mysql_dynamic.c
c0565f
+++ b/contrib/dlz/modules/mysql/dlz_mysql_dynamic.c
c0565f
@@ -64,12 +64,8 @@ typedef bool my_bool;
c0565f
  * many separate instances.
c0565f
  */
c0565f
 typedef struct {
c0565f
-#if PTHREADS
c0565f
 	db_list_t *db; /*%< handle to a list of DB */
c0565f
 	int dbcount;
c0565f
-#else  /* if PTHREADS */
c0565f
-	dbinstance_t *db; /*%< handle to DB */
c0565f
-#endif /* if PTHREADS */
c0565f
 
c0565f
 	unsigned int flags;
c0565f
 	char *dbname;
c0565f
@@ -112,7 +108,6 @@ mysql_destroy(dbinstance_t *db) {
c0565f
 	destroy_dbinstance(db);
c0565f
 }
c0565f
 
c0565f
-#if PTHREADS
c0565f
 /*%
c0565f
  * Properly cleans up a list of database instances.
c0565f
  * This function is only used when the module is compiled for
c0565f
@@ -175,7 +170,6 @@ mysql_find_avail_conn(mysql_instance_t *mysql) {
c0565f
 		   count);
c0565f
 	return (NULL);
c0565f
 }
c0565f
-#endif /* PTHREADS */
c0565f
 
c0565f
 /*%
c0565f
  * Allocates memory for a new string, and then constructs the new
c0565f
@@ -224,16 +218,8 @@ mysql_get_resultset(const char *zone, const char *record, const char *client,
c0565f
 	unsigned int j = 0;
c0565f
 	int qres = 0;
c0565f
 
c0565f
-#if PTHREADS
c0565f
 	/* find an available DBI from the list */
c0565f
 	dbi = mysql_find_avail_conn(db);
c0565f
-#else  /* PTHREADS */
c0565f
-	/*
c0565f
-	 * only 1 DBI - no need to lock instance lock either
c0565f
-	 * only 1 thread in the whole process, no possible contention.
c0565f
-	 */
c0565f
-	dbi = (dbinstance_t *)(db->db);
c0565f
-#endif /* PTHREADS */
c0565f
 
c0565f
 	if (dbi == NULL) {
c0565f
 		return (ISC_R_FAILURE);
c0565f
@@ -801,10 +787,8 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata,
c0565f
 	char *endp;
c0565f
 	int j;
c0565f
 	const char *helper_name;
c0565f
-#if PTHREADS
c0565f
 	int dbcount;
c0565f
 	int i;
c0565f
-#endif /* PTHREADS */
c0565f
 	va_list ap;
c0565f
 
c0565f
 	UNUSED(dlzname);
c0565f
@@ -823,13 +807,8 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata,
c0565f
 	}
c0565f
 	va_end(ap);
c0565f
 
c0565f
-#if PTHREADS
c0565f
 	/* if debugging, let user know we are multithreaded. */
c0565f
 	mysql->log(ISC_LOG_DEBUG(1), "MySQL module running multithreaded");
c0565f
-#else  /* PTHREADS */
c0565f
-	/* if debugging, let user know we are single threaded. */
c0565f
-	mysql->log(ISC_LOG_DEBUG(1), "MySQL module running single threaded");
c0565f
-#endif /* PTHREADS */
c0565f
 
c0565f
 	/* verify we have at least 4 arg's passed to the module */
c0565f
 	if (argc < 4) {
c0565f
@@ -901,7 +880,6 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata,
c0565f
 		free(tmp);
c0565f
 	}
c0565f
 
c0565f
-#if PTHREADS
c0565f
 	/* multithreaded build can have multiple DB connections */
c0565f
 	tmp = get_parameter_value(argv[1], "threads=");
c0565f
 	if (tmp == NULL) {
c0565f
@@ -934,7 +912,6 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata,
c0565f
 	 * append each new DBI to the end of the list
c0565f
 	 */
c0565f
 	for (i = 0; i < dbcount; i++) {
c0565f
-#endif /* PTHREADS */
c0565f
 		switch (argc) {
c0565f
 		case 4:
c0565f
 			result = build_dbinstance(NULL, NULL, NULL, argv[2],
c0565f
@@ -973,17 +950,9 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata,
c0565f
 			goto cleanup;
c0565f
 		}
c0565f
 
c0565f
-#if PTHREADS
c0565f
 		/* when multithreaded, build a list of DBI's */
c0565f
 		DLZ_LINK_INIT(dbi, link);
c0565f
 		DLZ_LIST_APPEND(*(mysql->db), dbi, link);
c0565f
-#else  /* if PTHREADS */
c0565f
-	/*
c0565f
-	 * when single threaded, hold onto the one connection
c0565f
-	 * instance.
c0565f
-	 */
c0565f
-	mysql->db = dbi;
c0565f
-#endif /* if PTHREADS */
c0565f
 
c0565f
 		/* create and set db connection */
c0565f
 		dbi->dbconn = mysql_init(NULL);
c0565f
@@ -1029,11 +998,9 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata,
c0565f
 			goto cleanup;
c0565f
 		}
c0565f
 
c0565f
-#if PTHREADS
c0565f
 		/* set DBI = null for next loop through. */
c0565f
 		dbi = NULL;
c0565f
 	}
c0565f
-#endif /* PTHREADS */
c0565f
 
c0565f
 	*dbdata = mysql;
c0565f
 
c0565f
@@ -1051,14 +1018,10 @@ cleanup:
c0565f
 void
c0565f
 dlz_destroy(void *dbdata) {
c0565f
 	mysql_instance_t *db = (mysql_instance_t *)dbdata;
c0565f
-#if PTHREADS
c0565f
 	/* cleanup the list of DBI's */
c0565f
 	if (db->db != NULL) {
c0565f
 		mysql_destroy_dblist((db_list_t *)(db->db));
c0565f
 	}
c0565f
-#else  /* PTHREADS */
c0565f
-	mysql_destroy(db);
c0565f
-#endif /* PTHREADS */
c0565f
 
c0565f
 	if (db->dbname != NULL) {
c0565f
 		free(db->dbname);
c0565f
diff --git a/contrib/dlz/modules/sqlite3/dlz_sqlite3_dynamic.c b/contrib/dlz/modules/sqlite3/dlz_sqlite3_dynamic.c
c0565f
index c2a8958d6a..459ae7f68d 100644
c0565f
--- a/contrib/dlz/modules/sqlite3/dlz_sqlite3_dynamic.c
c0565f
+++ b/contrib/dlz/modules/sqlite3/dlz_sqlite3_dynamic.c
c0565f
@@ -59,12 +59,8 @@
c0565f
  * many separate instances.
c0565f
  */
c0565f
 typedef struct {
c0565f
-#if PTHREADS
c0565f
 	db_list_t *db; /*%< handle to a list of DB */
c0565f
 	int dbcount;
c0565f
-#else  /* if PTHREADS */
c0565f
-	dbinstance_t *db; /*%< handle to DB */
c0565f
-#endif /* if PTHREADS */
c0565f
 
c0565f
 	char *dbname;
c0565f
 
c0565f
@@ -113,7 +109,6 @@ sqlite3_destroy(dbinstance_t *db) {
c0565f
 	destroy_dbinstance(db);
c0565f
 }
c0565f
 
c0565f
-#if PTHREADS
c0565f
 /*%
c0565f
  * Properly cleans up a list of database instances.
c0565f
  * This function is only used when the module is compiled for
c0565f
@@ -176,7 +171,6 @@ sqlite3_find_avail(sqlite3_instance_t *sqlite3) {
c0565f
 		     count);
c0565f
 	return (NULL);
c0565f
 }
c0565f
-#endif /* PTHREADS */
c0565f
 
c0565f
 /*%
c0565f
  * Allocates memory for a new string, and then constructs the new
c0565f
@@ -252,16 +246,8 @@ sqlite3_get_resultset(const char *zone, const char *record, const char *client,
c0565f
 		goto cleanup;
c0565f
 	}
c0565f
 
c0565f
-#if PTHREADS
c0565f
 	/* find an available DBI from the list */
c0565f
 	dbi = sqlite3_find_avail(db);
c0565f
-#else  /* PTHREADS */
c0565f
-	/*
c0565f
-	 * only 1 DBI - no need to lock instance lock either
c0565f
-	 * only 1 thread in the whole process, no possible contention.
c0565f
-	 */
c0565f
-	dbi = (dbinstance_t *)(db->db);
c0565f
-#endif /* PTHREADS */
c0565f
 
c0565f
 	if (dbi == NULL) {
c0565f
 		return (ISC_R_FAILURE);
c0565f
@@ -872,10 +858,8 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata,
c0565f
 	char *tmp = NULL;
c0565f
 	char *endp;
c0565f
 	const char *helper_name;
c0565f
-#if PTHREADS
c0565f
 	int dbcount;
c0565f
 	int i, ret;
c0565f
-#endif /* PTHREADS */
c0565f
 	va_list ap;
c0565f
 
c0565f
 	UNUSED(dlzname);
c0565f
@@ -894,13 +878,8 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata,
c0565f
 	}
c0565f
 	va_end(ap);
c0565f
 
c0565f
-#if PTHREADS
c0565f
 	/* if debugging, let user know we are multithreaded. */
c0565f
 	s3->log(ISC_LOG_DEBUG(1), "SQLite3 module: running multithreaded");
c0565f
-#else  /* PTHREADS */
c0565f
-	/* if debugging, let user know we are single threaded. */
c0565f
-	s3->log(ISC_LOG_DEBUG(1), "SQLite3 module: running single threaded");
c0565f
-#endif /* PTHREADS */
c0565f
 
c0565f
 	/* verify we have at least 4 arg's passed to the module */
c0565f
 	if (argc < 4) {
c0565f
@@ -925,7 +904,6 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata,
c0565f
 		goto cleanup;
c0565f
 	}
c0565f
 
c0565f
-#if PTHREADS
c0565f
 	/* multithreaded build can have multiple DB connections */
c0565f
 	tmp = get_parameter_value(argv[1], "threads=");
c0565f
 	if (tmp == NULL) {
c0565f
@@ -958,7 +936,6 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata,
c0565f
 	 * append each new DBI to the end of the list
c0565f
 	 */
c0565f
 	for (i = 0; i < dbcount; i++) {
c0565f
-#endif /* PTHREADS */
c0565f
 		switch (argc) {
c0565f
 		case 4:
c0565f
 			result = build_dbinstance(NULL, NULL, NULL, argv[2],
c0565f
@@ -1014,25 +991,15 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata,
c0565f
 			goto cleanup;
c0565f
 		}
c0565f
 
c0565f
-#if PTHREADS
c0565f
 		/* when multithreaded, build a list of DBI's */
c0565f
 		DLZ_LINK_INIT(dbi, link);
c0565f
 		DLZ_LIST_APPEND(*(s3->db), dbi, link);
c0565f
-#else  /* if PTHREADS */
c0565f
-	/*
c0565f
-	 * when single threaded, hold onto the one connection
c0565f
-	 * instance.
c0565f
-	 */
c0565f
-	s3->db = dbi;
c0565f
-#endif /* if PTHREADS */
c0565f
 
c0565f
 		dbi->dbconn = dbc;
c0565f
 		dbc = NULL;
c0565f
-#if PTHREADS
c0565f
 		/* set DBI = null for next loop through. */
c0565f
 		dbi = NULL;
c0565f
 	}
c0565f
-#endif /* PTHREADS */
c0565f
 
c0565f
 	*dbdata = s3;
c0565f
 	return (ISC_R_SUCCESS);
c0565f
@@ -1049,14 +1016,10 @@ cleanup:
c0565f
 void
c0565f
 dlz_destroy(void *dbdata) {
c0565f
 	sqlite3_instance_t *db = (sqlite3_instance_t *)dbdata;
c0565f
-#if PTHREADS
c0565f
 	/* cleanup the list of DBI's */
c0565f
 	if (db->db != NULL) {
c0565f
 		sqlite3_destroy_dblist((db_list_t *)(db->db));
c0565f
 	}
c0565f
-#else  /* PTHREADS */
c0565f
-	sqlite3_destroy(db);
c0565f
-#endif /* PTHREADS */
c0565f
 
c0565f
 	if (db->dbname != NULL) {
c0565f
 		free(db->dbname);
c0565f
-- 
c0565f
2.31.1
c0565f