From ced5ff2715ed834dfaba9a59361501926022521f Mon Sep 17 00:00:00 2001 From: Marius Tolzmann Date: Thu, 21 May 2015 10:19:20 +0200 Subject: [PATCH] mx_mysql: Add sleep to mx_mysql_connect_forever() --- mx_mysql.c | 2 +- mx_mysql.h | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/mx_mysql.c b/mx_mysql.c index bfe82dd..a7af4b6 100644 --- a/mx_mysql.c +++ b/mx_mysql.c @@ -699,7 +699,7 @@ int mx_mysql_connect(struct mx_mysql **mysql) return res; } -int mx_mysql_connect_forever(struct mx_mysql **mysql, unsigned int seconds) +int mx_mysql_connect_forever_sec(struct mx_mysql **mysql, unsigned int seconds) { int res; diff --git a/mx_mysql.h b/mx_mysql.h index e994bf7..cc5d02a 100644 --- a/mx_mysql.h +++ b/mx_mysql.h @@ -118,6 +118,13 @@ static inline void mx_mysql_bind_string3(struct mx_mysql_bind *b, int index, cha (b)[(c)].length = &((b)[(c)].buffer_length); \ } while (0) */ +#ifndef MX_MYSQL_FAIL_WAIT_DEFAULT +# ifdef MX_CALLOC_FAIL_WAIT_DEFAULT +# define MX_MYSQL_FAIL_WAIT_DEFAULT MX_CALLOC_FAIL_WAIT_DEFAULT +# else +# define MX_MYSQL_FAIL_WAIT_DEFAULT 5 +# endif +#endif #define mx_mysql_print_error(mysql) \ mx_log_err("MySQL: ERROR %u (%s): %s\n", \ @@ -144,7 +151,9 @@ char *mx_mysql_option_get_default_file(struct mx_mysql *mysql); char *mx_mysql_option_get_default_group(struct mx_mysql *mysql); int mx_mysql_connect(struct mx_mysql **mysql); -int mx_mysql_connect_forever(struct mx_mysql **mysql, unsigned int seconds); +int mx_mysql_connect_forever_sec(struct mx_mysql **mysql, unsigned int seconds); +#define mx_mysql_connect_forever(m) mx_mysql_connect_forever_sec((m), MX_MYSQL_FAIL_WAIT_DEFAULT) + int mx_mysql_disconnect(struct mx_mysql *mysql); int mx_mysql_end(void);