From a0d595ca1e6bc4362c01cd427f674a3bf0a243cb Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Sun, 18 Jul 2004 15:43:05 +0300 Subject: [PATCH] Fixed reconnecting to PostgreSQL. --HG-- branch : HEAD --- src/auth/db-pgsql.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/auth/db-pgsql.c b/src/auth/db-pgsql.c index edd166b2b2..8056c45566 100644 --- a/src/auth/db-pgsql.c +++ b/src/auth/db-pgsql.c @@ -91,13 +91,15 @@ static int pgsql_conn_open(struct pgsql_connection *conn) if (conn->connected) return TRUE; - if (conn->pg == NULL) { - conn->pg = PQconnectdb(conn->set.connect); - if (PQstatus(conn->pg) != CONNECTION_OK) { - i_error("PGSQL: Can't connect to database %s", - conn->set.connect); - return FALSE; - } + i_assert(conn->pg == NULL); + + conn->pg = PQconnectdb(conn->set.connect); + if (PQstatus(conn->pg) != CONNECTION_OK) { + i_error("PGSQL: Can't connect to database %s", + conn->set.connect); + PQfinish(conn->pg); + conn->pg = NULL; + return FALSE; } conn->connected = TRUE; -- 2.47.3