[netfilter-cvslog] r6302 - branches/ulog/ulogd2/output/mysql

laforge at netfilter.org laforge at netfilter.org
Thu Dec 8 09:17:38 CET 2005


Author: laforge at netfilter.org
Date: 2005-12-08 09:17:31 +0100 (Thu, 08 Dec 2005)
New Revision: 6302

Modified:
   branches/ulog/ulogd2/output/mysql/ulogd_output_MYSQL.c
Log:
more verbose error reporting


Modified: branches/ulog/ulogd2/output/mysql/ulogd_output_MYSQL.c
===================================================================
--- branches/ulog/ulogd2/output/mysql/ulogd_output_MYSQL.c	2005-12-08 07:27:02 UTC (rev 6301)
+++ branches/ulog/ulogd2/output/mysql/ulogd_output_MYSQL.c	2005-12-08 08:17:31 UTC (rev 6302)
@@ -322,13 +322,17 @@
 	struct ulogd_key *f, *f2;
 	int i;
 
-	if (!mi->dbh)
+	if (!mi->dbh) {
+		ulogd_log(ULOGD_ERROR, "no database handle\n");
 		return -1;
+	}
 
 	result = mysql_list_fields(mi->dbh, 
 				   table_ce(upi->config_kset).u.string, NULL);
-	if (!result)
+	if (!result) {
+		ulogd_log(ULOGD_ERROR, "error in list_fields()\n");
 		return -1;
+	}
 
 	/* Thea idea here is that we can create a pluginstance specific input
 	 * key array by not specifyling a plugin input key list.  ulogd core
@@ -341,10 +345,12 @@
 		free(upi->input.keys);
 
 	upi->input.num_keys = mysql_num_fields(result);
+	ulogd_log(ULOGD_DEBUG, "%u fields in table\n", upi->input.num_keys);
 	upi->input.keys = malloc(sizeof(struct ulogd_key) * 
 						upi->input.num_keys);
 	if (!upi->input.keys) {
 		upi->input.num_keys = 0;
+		ulogd_log(ULOGD_ERROR, "ENOMEM\n");
 		return -ENOMEM;
 	}
 	
@@ -361,7 +367,7 @@
 		while ((underscore = strchr(buf, '_')))
 			*underscore = '.';
 
-		DEBUGP("field '%s' found: ", buf);
+		DEBUGP("field '%s' found\n", buf);
 
 		/* add it u list of input keys */
 		strncpy(upi->input.keys[i].name, buf, ULOGD_MAX_KEYLEN);
@@ -452,21 +458,6 @@
 }
 #endif
 
-static void signal_mysql(struct ulogd_pluginstance *upi,
-			 int signal)
-{
-	switch (signal) {
-	case SIGHUP:
-		stop_mysql(upi);
-		if (configure_mysql(upi) < 0)
-			return;
-		start_mysql(upi);
-		break;
-	default:
-		break;
-	}
-}
-
 static int configure_mysql(struct ulogd_pluginstance *upi,
 			   struct ulogd_pluginstance_stack *stack)
 {
@@ -488,11 +479,15 @@
 		      user_ce(upi->config_kset).u.string,
 		      pass_ce(upi->config_kset).u.string,
 		      db_ce(upi->config_kset).u.string);
-	if (ret < 0)
+	if (ret < 0) {
+		ulogd_log(ULOGD_ERROR, "error in open_db\n");
 		return ret;
+	}
 
 	/* Third: Determine required input keys for given table */
 	ret = mysql_get_columns(upi);
+	if (ret < 0)
+		ulogd_log(ULOGD_ERROR, "error in get_columns\n");
 	
 	/* Close database, since ulogd core could just call configure
 	 * but abort during input key resolving routines.  configure
@@ -539,6 +534,21 @@
 	return 0;
 }
 
+static void signal_mysql(struct ulogd_pluginstance *upi,
+			 int signal)
+{
+	switch (signal) {
+	case SIGHUP:
+		/* reopen database connection */
+		stop_mysql(upi);
+		start_mysql(upi);
+		break;
+	default:
+		break;
+	}
+}
+
+
 static struct ulogd_plugin mysql_plugin = {
 	.name = "MYSQL",
 	.input = {




More information about the netfilter-cvslog mailing list