浏览代码

modules_k/presence: Use non-pooled connections (where supported) when using notifier processes

- 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 年之前
父节点
当前提交
b882818b0e
共有 1 个文件被更改,包括 12 次插入6 次删除
  1. 12 6
      modules_k/presence/presence.c

+ 12 - 6
modules_k/presence/presence.c

@@ -498,9 +498,12 @@ static int child_init(int rank)
 		LM_CRIT("child_init: database not bound\n");
 		return -1;
 	}
-	if (pa_db)
-		return 0;
-	pa_db = pa_dbf.init(&db_url);
+	/* Do not pool the connections where possible when running notifier
+       processes. */
+	if (pres_notifier_processes > 0 && pa_dbf.init2)
+		pa_db = pa_dbf.init2(&db_url, DB_POOLING_NONE);
+	else
+		pa_db = pa_dbf.init(&db_url);
 	if (!pa_db)
 	{
 		LM_ERR("child %d: unsuccessful connecting to database\n", rank);
@@ -564,9 +567,12 @@ static int mi_child_init(void)
 		LM_CRIT("database not bound\n");
 		return -1;
 	}
-	if (pa_db)
-		return 0;
-	pa_db = pa_dbf.init(&db_url);
+	/* Do not pool the connections where possible when running notifier
+       processes. */
+	if (pres_notifier_processes > 0 && pa_dbf.init2)
+		pa_db = pa_dbf.init2(&db_url, DB_POOLING_NONE);
+	else
+		pa_db = pa_dbf.init(&db_url);
 	if (!pa_db)
 	{
 		LM_ERR("connecting database\n");