dovecot-2.2: pgsql: Include connect state string on connect fail...

dovecot at dovecot.org dovecot at dovecot.org
Thu May 14 10:36:02 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/a0dd9dad3b8c
changeset: 18689:a0dd9dad3b8c
user:      Timo Sirainen <tss at iki.fi>
date:      Thu May 14 13:33:59 2015 +0300
description:
pgsql: Include connect state string on connect failure errors.

diffstat:

 src/lib-sql/driver-pgsql.c |  13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diffs (59 lines):

diff -r 05e14a49507f -r a0dd9dad3b8c src/lib-sql/driver-pgsql.c
--- a/src/lib-sql/driver-pgsql.c	Thu May 14 11:27:04 2015 +0300
+++ b/src/lib-sql/driver-pgsql.c	Thu May 14 13:33:59 2015 +0300
@@ -26,6 +26,7 @@
 	struct sql_result *sync_result;
 
 	char *error;
+	const char *connect_state;
 
 	unsigned int fatal_error:1;
 };
@@ -148,16 +149,18 @@
 
 	switch (ret) {
 	case PGRES_POLLING_READING:
+		db->connect_state = "wait for input";
 		io_dir = IO_READ;
 		break;
 	case PGRES_POLLING_WRITING:
+		db->connect_state = "wait for output";
 		io_dir = IO_WRITE;
 		break;
 	case PGRES_POLLING_OK:
 		break;
 	case PGRES_POLLING_FAILED:
-		i_error("%s: Connect failed to database %s: %s",
-			pgsql_prefix(db), PQdb(db->pg), last_error(db));
+		i_error("%s: Connect failed to database %s: %s (state: %s)",
+			pgsql_prefix(db), PQdb(db->pg), last_error(db), db->connect_state);
 		driver_pgsql_close(db);
 		return;
 	}
@@ -168,6 +171,7 @@
 	}
 
 	if (io_dir == 0) {
+		db->connect_state = "connected";
 		if (db->to_connect != NULL)
 			timeout_remove(&db->to_connect);
 		driver_pgsql_set_state(db, SQL_DB_STATE_IDLE);
@@ -183,8 +187,8 @@
 {
 	unsigned int secs = ioloop_time - db->api.last_connect_try;
 
-	i_error("%s: Connect failed: Timeout after %u seconds",
-		pgsql_prefix(db), secs);
+	i_error("%s: Connect failed: Timeout after %u seconds (state: %s)",
+		pgsql_prefix(db), secs, db->connect_state);
 	driver_pgsql_close(db);
 }
 
@@ -213,6 +217,7 @@
 	i_assert(db->to_connect == NULL);
 	db->to_connect = timeout_add(SQL_CONNECT_TIMEOUT_SECS * 1000,
 				     driver_pgsql_connect_timeout, db);
+	db->connect_state = "connecting";
 	db->io = io_add(PQsocket(db->pg), IO_WRITE, connect_callback, db);
 	db->io_dir = IO_WRITE;
 	driver_pgsql_set_state(db, SQL_DB_STATE_CONNECTING);


More information about the dovecot-cvs mailing list