]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Fixed reconnecting to PostgreSQL.
authorTimo Sirainen <tss@iki.fi>
Sun, 18 Jul 2004 12:43:05 +0000 (15:43 +0300)
committerTimo Sirainen <tss@iki.fi>
Sun, 18 Jul 2004 12:43:05 +0000 (15:43 +0300)
--HG--
branch : HEAD

src/auth/db-pgsql.c

index edd166b2b2b1d2783860b3556acfba870522ab0f..8056c455664c9051ece1be64d6f96a5cb4e5f66f 100644 (file)
@@ -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;