[mod_mariadb] Fix reconnect during db failover/restart

This commit is contained in:
Nathan Neulinger 2020-03-23 11:55:00 -05:00 committed by GitHub
parent 9b0cfefce7
commit 477086b3e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -53,6 +53,8 @@ int mariadb_db_set_connection(MYSQL *mysql, enum enum_server_command command, co
size_t length, my_bool skipp_check, void *opt_arg);
my_bool mariadb_db_dsn_reconnect(MYSQL *mysql);
my_bool reconnect = 1;
#define DEFAULT_MARIADB_RETRIES 120
#ifndef MIN
@ -474,10 +476,13 @@ switch_status_t mariadb_handle_connect(mariadb_handle_t *handle)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Connecting %s\n", handle->dsn);
mysql_init(&handle->con);
// Enable non-blocking operation
// https://mariadb.com/kb/en/library/using-the-non-blocking-library/
/* Enable non-blocking operation */
/* https://mariadb.com/kb/en/library/using-the-non-blocking-library */
mysql_options(&handle->con, MYSQL_OPT_NONBLOCK, 0);
/* Enable automatic reconnect with the mariadb_reconnect function, without this that function does not work */
mysql_options(&handle->con, MYSQL_OPT_RECONNECT, &reconnect);
/* set timeouts to 300 microseconds */
/*int default_timeout = 3;
mysql_options(&handle->con, MYSQL_OPT_READ_TIMEOUT, &default_timeout);