summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlaforge <laforge>2005-08-01 06:49:59 +0000
committerlaforge <laforge>2005-08-01 06:49:59 +0000
commitdde78609dede4293f16fb8763d254f2a54d23d28 (patch)
treea8e81f9952ad091068958e328d7ac28884fa2b2f
parent42f675fa5cdd22fcf95e0e85439b08b821acda92 (diff)
Today we have had to reboot our firewall and due to a loose crossover
cable (sigh) between the firewall and the logger machine, ulogd was unable to connect to the mysql server. That resulted effectively a hang in the boot process: being unable to connect mysql_real_connect did not return (or the socket timeout was so long I was unable to wait out), ulogd could not reach the point to fork and init could not start the daemons, processes following ulogd. The attached simple patch adds the connect_timeout parameter to the MYSQL section and calls mysql_option when connect_timeout is set. (Jozsef Kadlecsik)
-rw-r--r--ulogd/mysql/ulogd_MYSQL.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/ulogd/mysql/ulogd_MYSQL.c b/ulogd/mysql/ulogd_MYSQL.c
index 7765c71..9014a29 100644
--- a/ulogd/mysql/ulogd_MYSQL.c
+++ b/ulogd/mysql/ulogd_MYSQL.c
@@ -125,6 +125,12 @@ static config_entry_t reconnect_ce = {
.type = CONFIG_TYPE_INT,
};
+static config_entry_t connect_timeout_ce = {
+ .next = &reconnect_ce,
+ .key = "connect_timeout",
+ .type = CONFIG_TYPE_INT,
+};
+
static int _mysql_init_db(ulog_iret_t *result);
/* our main output function, called by ulogd */
@@ -364,6 +370,9 @@ static int mysql_open_db(char *server, int port, char *user, char *pass,
if (!dbh)
return -1;
+ if (connect_timeout_ce.u.value)
+ mysql_options(dbh, MYSQL_OPT_CONNECT_TIMEOUT, (const char *) &connect_timeout_ce.u.value);
+
if (!mysql_real_connect(dbh, server, user, pass, db, port, NULL, 0))
return -1;
@@ -422,7 +431,7 @@ static int _mysql_init_db(ulog_iret_t *result)
static int _mysql_init(void)
{
/* have the opts parsed */
- config_parse_file("MYSQL", &reconnect_ce);
+ config_parse_file("MYSQL", &connect_timeout_ce);
return _mysql_init_db(NULL);
}