]> git.ipfire.org Git - thirdparty/ulogd2.git/commitdiff
From: Eric Leblond <eric@inl.fr>
author/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org </C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org>
Sun, 3 Feb 2008 11:46:58 +0000 (11:46 +0000)
committer/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org </C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org>
Sun, 3 Feb 2008 11:46:58 +0000 (11:46 +0000)
MySQL client library does not reconnect automatically since 5.0.

output/mysql/ulogd_output_MYSQL.c

index 1826c03f85c684eca3b9bf65b83216110aa2737c..800d79dfa5b31d893758406023e25c0523af8432 100644 (file)
@@ -180,6 +180,9 @@ static int open_db_mysql(struct ulogd_pluginstance *upi)
        char *user = user_ce(upi->config_kset).u.string;
        char *pass = pass_ce(upi->config_kset).u.string;
        char *db = db_ce(upi->config_kset).u.string;
+#ifdef MYSQL_OPT_RECONNECT
+       my_bool trueval = 1;
+#endif 
 
        mi->dbh = mysql_init(NULL);
        if (!mi->dbh) {
@@ -190,6 +193,11 @@ static int open_db_mysql(struct ulogd_pluginstance *upi)
        if (connect_timeout)
                mysql_options(mi->dbh, MYSQL_OPT_CONNECT_TIMEOUT, 
                              (const char *) &connect_timeout);
+#ifdef MYSQL_OPT_RECONNECT
+#  if defined(MYSQL_VERSION_ID) && (MYSQL_VERSION_ID >= 50019)
+       mysql_options(mi->dbh, MYSQL_OPT_RECONNECT, &trueval);
+#  endif
+#endif 
 
        if (!mysql_real_connect(mi->dbh, server, user, pass, db, port, NULL, 0)) {
                ulogd_log(ULOGD_ERROR, "can't connect to db: %s\n",
@@ -197,6 +205,12 @@ static int open_db_mysql(struct ulogd_pluginstance *upi)
                return -1;
        }
                
+#ifdef MYSQL_OPT_RECONNECT
+#  if defined(MYSQL_VERSION_ID) && (MYSQL_VERSION_ID < 50019)
+       mysql_options(mi->dbh, MYSQL_OPT_RECONNECT, &trueval);
+#  endif
+#endif
+
        return 0;
 }