Mercurial > dovecot > core-2.2
changeset 13491:11273f581686
lib-sql: If MySQL connect takes more than 1 sec, don't try to reconnect for that many secs.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 15 Sep 2011 13:45:35 +0300 |
parents | c056bd23fdcc |
children | 1b829680dce4 |
files | src/lib-sql/driver-mysql.c |
diffstat | 1 files changed, 4 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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",