]> granicus.if.org Git - pdns/commitdiff
John Leach discovered our MySQL based backends would wait for ages on a failing MySQL...
authorBert Hubert <bert.hubert@netherlabs.nl>
Sun, 1 May 2011 20:28:05 +0000 (20:28 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Sun, 1 May 2011 20:28:05 +0000 (20:28 +0000)
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

modules/gmysqlbackend/smysql.cc

index e7cb4fdfc36e68032b141ffb954785d4d81abe3e..12636f4d2e66f22abeaab6f1092fcac16851ff54 100644 (file)
@@ -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(),