diff --git a/extensions/mysql/mysql/MyDriver.cpp b/extensions/mysql/mysql/MyDriver.cpp index c6941821..9221c6ff 100644 --- a/extensions/mysql/mysql/MyDriver.cpp +++ b/extensions/mysql/mysql/MyDriver.cpp @@ -96,11 +96,16 @@ MYSQL *Connect(const DatabaseInfo *info, char *error, size_t maxlength) MYSQL *mysql = mysql_init(NULL); const char *host = NULL, *socket = NULL; + decltype(info->maxTimeout) timeout = 60; if (info->maxTimeout > 0) { - mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, (const char *)&(info->maxTimeout)); + timeout = info->maxTimeout; } + mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, (const char *)&timeout); + mysql_options(mysql, MYSQL_OPT_READ_TIMEOUT, (const char *)&timeout); + mysql_options(mysql, MYSQL_OPT_WRITE_TIMEOUT, (const char *)&timeout); + /* Have MySQL automatically reconnect if it times out or loses connection. * This will prevent "MySQL server has gone away" errors after a while. */