Module: sip-router Branch: master Commit: b882818b0e82b8b286cbc6cd0e5c986db5b9fb51 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=b882818b...
Author: Peter Dunkley peter.dunkley@crocodile-rcs.com Committer: Peter Dunkley peter.dunkley@crocodile-rcs.com Date: Sun May 13 01:23:09 2012 +0100
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.
---
modules_k/presence/presence.c | 18 ++++++++++++------ 1 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/modules_k/presence/presence.c b/modules_k/presence/presence.c index a3e52c4..b960d5e 100644 --- a/modules_k/presence/presence.c +++ b/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");