Module: sip-router
Branch: master
Commit: 7c10eae7255450b6a176dc03d0d5f516a6dacc10
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=7c10eaeā¦
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Tue Jan 18 11:49:12 2011 +0100
db_postgres: reconnect tuning in submit query
- don't attempt to reconnect if the connection state is ok upon
submitting query, the error might be something else and will be
reported when fetching the result
---
modules/db_postgres/km_dbase.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/modules/db_postgres/km_dbase.c b/modules/db_postgres/km_dbase.c
index 1558e49..c01d37a 100644
--- a/modules/db_postgres/km_dbase.c
+++ b/modules/db_postgres/km_dbase.c
@@ -151,14 +151,15 @@ static int db_postgres_submit_query(const db1_con_t* _con, const
str* _s)
/* exec the query */
if (PQsendQuery(CON_CONNECTION(_con), _s->s)) {
pqresult = PQresultStatus(CON_RESULT(_con));
- if(pqresult!=PGRES_FATAL_ERROR)
+ if((pqresult!=PGRES_FATAL_ERROR)
+ || (PQstatus(CON_CONNECTION(_con))==CONNECTION_OK))
{
LM_DBG("sending query ok: %p (%d) - [%.*s]\n",
_con, pqresult, _s->len, _s->s);
return 0;
}
- LM_WARN("postgres result check failed with code %d (%s)\n", pqresult,
- PQresStatus(pqresult));
+ LM_WARN("postgres result check failed with code %d (%s)\n",
+ pqresult, PQresStatus(pqresult));
}
LM_WARN("postgres query command failed, connection status %d,"
" error [%s]\n", PQstatus(CON_CONNECTION(_con)),