dovecot-2.1: lib-sql: If MySQL connect takes more than 1 sec, do...

dovecot at dovecot.org dovecot at dovecot.org
Fri Sep 16 16:59:32 EEST 2011


details:   http://hg.dovecot.org/dovecot-2.1/rev/11273f581686
changeset: 13491:11273f581686
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Sep 15 13:45:35 2011 +0300
description:
lib-sql: If MySQL connect takes more than 1 sec, don't try to reconnect for that many secs.

diffstat:

 src/lib-sql/driver-mysql.c |  5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diffs (28 lines):

diff -r c056bd23fdcc -r 11273f581686 src/lib-sql/driver-mysql.c
--- a/src/lib-sql/driver-mysql.c	Thu Sep 15 13:41:03 2011 +0300
+++ b/src/lib-sql/driver-mysql.c	Thu Sep 15 13:45:35 2011 +0300
@@ -63,6 +63,7 @@
 	struct mysql_db *db = (struct mysql_db *)_db;
 	const char *unix_socket, *host;
 	unsigned long client_flags = db->client_flags;
+	unsigned int secs_used;
 	bool failed;
 
 	i_assert(db->api.state == SQL_DB_STATE_DISCONNECTED);
@@ -108,13 +109,15 @@
 	failed = mysql_real_connect(db->mysql, host, db->user, db->password,
 				    db->dbname, db->port, unix_socket,
 				    client_flags) == NULL;
-	alarm(0);
+	secs_used = SQL_CONNECT_TIMEOUT_SECS - alarm(0);
 	if (failed) {
 		/* connecting could have taken a while. make sure that any
 		   timeouts that get added soon will get a refreshed
 		   timestamp. */
 		io_loop_time_refresh();
 
+		if (db->api.connect_delay < secs_used)
+			db->api.connect_delay = secs_used;
 		sql_db_set_state(&db->api, SQL_DB_STATE_DISCONNECTED);
 		i_error("%s: Connect failed to database (%s): %s - "
 			"waiting for %u seconds before retry",


More information about the dovecot-cvs mailing list