Переглянути джерело

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
Daniel-Constantin Mierla 14 роки тому
батько
коміт
7c10eae725
1 змінених файлів з 4 додано та 3 видалено
  1. 4 3
      modules/db_postgres/km_dbase.c

+ 4 - 3
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)),