Selaa lähdekoodia

modules_k/pua: Use non-pooled connections in db only mode (where supported)

- This helps with databases (such as PostgreSQL, which is the only one that
  currently supports specifying non-pooled connections) that create a server
  process per client connection.
Peter Dunkley 13 vuotta sitten
vanhempi
commit
126131202c
1 muutettua tiedostoa jossa 10 lisäystä ja 2 poistoa
  1. 10 2
      modules_k/pua/pua.c

+ 10 - 2
modules_k/pua/pua.c

@@ -296,7 +296,11 @@ static int child_init(int rank)
 		LM_CRIT("database not bound\n");
 		LM_CRIT("database not bound\n");
 		return -1;
 		return -1;
 	}
 	}
-	pua_db = pua_dbf.init(&db_url);
+	/* In DB only mode do not pool the connections where possible. */
+	if (dbmode == PUA_DB_ONLY && pua_dbf.init2)
+		pua_db = pua_dbf.init2(&db_url, DB_POOLING_NONE);
+	else
+		pua_db = pua_dbf.init(&db_url);
 	if (!pua_db)
 	if (!pua_db)
 	{
 	{
 		LM_ERR("Child %d: connecting to database failed\n", rank);
 		LM_ERR("Child %d: connecting to database failed\n", rank);
@@ -321,7 +325,11 @@ static int mi_child_init(void)
 		LM_CRIT("database not bound\n");
 		LM_CRIT("database not bound\n");
 		return -1;
 		return -1;
 	}
 	}
-	pua_db = pua_dbf.init(&db_url);
+	/* In DB only mode do not pool the connections where possible. */
+	if (dbmode == PUA_DB_ONLY && pua_dbf.init2)
+		pua_db = pua_dbf.init2(&db_url, DB_POOLING_NONE);
+	else
+		pua_db = pua_dbf.init(&db_url);
 	if (!pua_db)
 	if (!pua_db)
 	{
 	{
 		LM_ERR("connecting to database failed\n");
 		LM_ERR("connecting to database failed\n");