dovecot-2.2: mysql: Use the correct way of setting a connect tim...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Oct 20 15:23:12 UTC 2015
details: http://hg.dovecot.org/dovecot-2.2/rev/5288c66c7d69
changeset: 19319:5288c66c7d69
user: Timo Sirainen <tss at iki.fi>
date: Tue Oct 20 16:56:23 2015 +0300
description:
mysql: Use the correct way of setting a connect timeout.
I'm not sure if this didn't exist earlier, or if I just somehow missed it.
diffstat:
src/lib-sql/driver-mysql.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diffs (39 lines):
diff -r f9a143c630a5 -r 5288c66c7d69 src/lib-sql/driver-mysql.c
--- a/src/lib-sql/driver-mysql.c Tue Oct 20 15:29:07 2015 +0300
+++ b/src/lib-sql/driver-mysql.c Tue Oct 20 16:56:23 2015 +0300
@@ -76,7 +76,8 @@
struct mysql_db *db = (struct mysql_db *)_db;
const char *unix_socket, *host;
unsigned long client_flags = db->client_flags;
- unsigned int secs_used;
+ unsigned int secs_used, connect_timeout = SQL_CONNECT_TIMEOUT_SECS;
+ time_t start_time;
bool failed;
i_assert(db->api.state == SQL_DB_STATE_DISCONNECTED);
@@ -96,6 +97,7 @@
db->option_file);
}
+ mysql_options(db->mysql, MYSQL_OPT_CONNECT_TIMEOUT, &connect_timeout);
mysql_options(db->mysql, MYSQL_READ_DEFAULT_GROUP,
db->option_group != NULL ? db->option_group : "client");
@@ -118,15 +120,15 @@
#endif
}
- alarm(SQL_CONNECT_TIMEOUT_SECS);
#ifdef CLIENT_MULTI_RESULTS
client_flags |= CLIENT_MULTI_RESULTS;
#endif
/* CLIENT_MULTI_RESULTS allows the use of stored procedures */
+ start_time = time(NULL);
failed = mysql_real_connect(db->mysql, host, db->user, db->password,
db->dbname, db->port, unix_socket,
client_flags) == NULL;
- secs_used = SQL_CONNECT_TIMEOUT_SECS - alarm(0);
+ secs_used = time(NULL) - start_time;
if (failed) {
/* connecting could have taken a while. make sure that any
timeouts that get added soon will get a refreshed
More information about the dovecot-cvs
mailing list