From: Bert Hubert Date: Sun, 1 May 2011 20:28:05 +0000 (+0000) Subject: John Leach discovered our MySQL based backends would wait for ages on a failing MySQL... X-Git-Tag: auth-3.0~60 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=45ddd0c5d39846d06f33b125e04b316076bd2cd9;p=pdns John Leach discovered our MySQL based backends would wait for ages on a failing MySQL server. This patch he contributed reduces the timeout significantly, which is especially useful with haproxy and mysqlproxy. git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@2189 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- diff --git a/modules/gmysqlbackend/smysql.cc b/modules/gmysqlbackend/smysql.cc index e7cb4fdfc..12636f4d2 100644 --- a/modules/gmysqlbackend/smysql.cc +++ b/modules/gmysqlbackend/smysql.cc @@ -18,6 +18,9 @@ SMySQL::SMySQL(const string &database, const string &host, uint16_t port, const mysql_options(&d_db, MYSQL_READ_DEFAULT_GROUP, "client"); my_bool reconnect = 1; mysql_options(&d_db, MYSQL_OPT_RECONNECT, &reconnect); + unsigned int timeout = 10; + mysql_options(&d_db, MYSQL_OPT_READ_TIMEOUT, &timeout); + mysql_options(&d_db, MYSQL_OPT_WRITE_TIMEOUT, &timeout); if (!mysql_real_connect(&d_db, host.empty() ? 0 : host.c_str(), user.empty() ? 0 : user.c_str(),