Mercurial > dovecot > core-2.2
changeset 18689:a0dd9dad3b8c
pgsql: Include connect state string on connect failure errors.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 14 May 2015 13:33:59 +0300 |
parents | 05e14a49507f |
children | a2c3a0f671a6 |
files | src/lib-sql/driver-pgsql.c |
diffstat | 1 files changed, 9 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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);