diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2020-05-17 10:16:52 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2020-05-17 10:16:52 +0300 |
commit | 6dfa98f3fdd5523086fbd240498fd1b8a4850289 (patch) | |
tree | 8042e1f1d99b29521f4f054c8da1ad3bf7be354e /src/sql.c | |
parent | d7e0d11445cd9972ac6f20e39878e3dc8bc7fe12 (diff) | |
download | wydawca-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
Diffstat (limited to 'src/sql.c')
-rw-r--r-- | src/sql.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -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 |