aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2020-05-17 10:16:52 +0300
committerSergey Poznyakoff <gray@gnu.org>2020-05-17 10:16:52 +0300
commit6dfa98f3fdd5523086fbd240498fd1b8a4850289 (patch)
tree8042e1f1d99b29521f4f054c8da1ad3bf7be354e
parentd7e0d11445cd9972ac6f20e39878e3dc8bc7fe12 (diff)
downloadwydawca-6dfa98f3fdd5523086fbd240498fd1b8a4850289.tar.gz
wydawca-6dfa98f3fdd5523086fbd240498fd1b8a4850289.tar.bz2
Enable automatic reconnection in mysql
* src/sql.c (sql_init_dictionary): Enable automatic reconnection (sql_open): Call mysql_ping
-rw-r--r--src/sql.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/sql.c b/src/sql.c
index 65cc5df..ff8d3c6 100644
--- a/src/sql.c
+++ b/src/sql.c
@@ -67,6 +67,8 @@ sql_init_dictionary(struct dictionary *dict)
}
if (conn->initcount++ == 0) {
+ my_bool reconnect = 1;
+
mysql_init(&conn->mysql);
if (conn->config_file)
@@ -76,6 +78,8 @@ sql_init_dictionary(struct dictionary *dict)
mysql_options(&conn->mysql, MYSQL_READ_DEFAULT_GROUP,
conn->config_group);
+ mysql_options(&conn->mysql, MYSQL_OPT_RECONNECT, &reconnect);
+
if (conn->cacert)
mysql_ssl_set(&conn->mysql, NULL, NULL, conn->cacert,
NULL, NULL);
@@ -97,7 +101,9 @@ sql_init_dictionary(struct dictionary *dict)
void *
sql_open(struct dictionary *dict)
{
- return dict->storage;
+ struct sqlconn *conn = dict->storage;
+ mysql_ping(&conn->mysql);
+ return conn;
}
int

Return to:

Send suggestions and report system problems to the System administrator.