[dovecot-cvs] dovecot/src/auth db-pgsql.c,1.6,1.7

cras at dovecot.org cras at dovecot.org
Sun Jul 18 15:43:07 EEST 2004


Update of /home/cvs/dovecot/src/auth
In directory talvi:/tmp/cvs-serv12766

Modified Files:
	db-pgsql.c 
Log Message:
Fixed reconnecting to PostgreSQL.



Index: db-pgsql.c
===================================================================
RCS file: /home/cvs/dovecot/src/auth/db-pgsql.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- db-pgsql.c	26 Apr 2004 21:20:15 -0000	1.6
+++ db-pgsql.c	18 Jul 2004 12:43:05 -0000	1.7
@@ -91,13 +91,15 @@
 	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;



More information about the dovecot-cvs mailing list