summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2012-05-03 12:32:03 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2012-05-03 12:32:03 +0200
commita34e46801b52b2614f9f3f16eb23e6fd14de6288 (patch)
treee68c47111bcdb3095f21221e5a51bf943d076ae9
parent6f529cc2daafb791ca1bbef8a3ee128833db19c1 (diff)
downloadrsyslog-a34e46801b52b2614f9f3f16eb23e6fd14de6288.tar.gz
rsyslog-a34e46801b52b2614f9f3f16eb23e6fd14de6288.tar.xz
rsyslog-a34e46801b52b2614f9f3f16eb23e6fd14de6288.zip
bugfix: ommysql did not properly init/exit the mysql runtime library
This could lead to segfaults. Triggering condition: multiple action instances using ommysql. Thanks to Tomas Heinrich for reporting this problem and providing an initial patch (which my solution is based on, I need to add more code to clean the mess up).
-rw-r--r--ChangeLog5
-rw-r--r--plugins/ommysql/ommysql.c10
2 files changed, 14 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index eb99a245..03c5ca93 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
---------------------------------------------------------------------------
Version 5.8.11 [V5-stable] 2012-04-??
+- bugfix: ommysql did not properly init/exit the mysql runtime library
+ this could lead to segfaults. Triggering condition: multiple action
+ instances using ommysql. Thanks to Tomas Heinrich for reporting this
+ problem and providing an initial patch (which my solution is based on,
+ I need to add more code to clean the mess up).
- bugfix: rsyslog did not terminate when delayable inputs were blocked
due to unvailable sources. Fixes:
http://bugzilla.adiscon.com/show_bug.cgi?id=299
diff --git a/plugins/ommysql/ommysql.c b/plugins/ommysql/ommysql.c
index 58e347bf..01f6a844 100644
--- a/plugins/ommysql/ommysql.c
+++ b/plugins/ommysql/ommysql.c
@@ -90,7 +90,6 @@ static void closeMySQL(instanceData *pData)
ASSERT(pData != NULL);
if(pData->f_hmysql != NULL) { /* just to be on the safe side... */
- mysql_server_end();
mysql_close(pData->f_hmysql);
pData->f_hmysql = NULL;
}
@@ -319,6 +318,7 @@ ENDparseSelectorAct
BEGINmodExit
CODESTARTmodExit
+ mysql_server_end();
ENDmodExit
@@ -346,6 +346,14 @@ CODESTARTmodInit
*ipIFVersProvided = CURR_MOD_IF_VERSION; /* we only support the current interface specification */
CODEmodInit_QueryRegCFSLineHdlr
CHKiRet(objUse(errmsg, CORE_COMPONENT));
+
+ /* we need to init the MySQL library. If that fails, we cannot run */
+ if(mysql_server_init(0, NULL, NULL)) {
+ errmsg.LogError(0, NO_ERRCODE, "ommysql: mysql_server_init() failed, plugin "
+ "can not run");
+ ABORT_FINALIZE(RS_RET_ERR);
+ }
+
/* register our config handlers */
CHKiRet(omsdRegCFSLineHdlr((uchar *)"actionommysqlserverport", 0, eCmdHdlrInt, NULL, &iSrvPort, STD_LOADABLE_MODULE_ID));
CHKiRet(omsdRegCFSLineHdlr((uchar *)"resetconfigvariables", 1, eCmdHdlrCustomHandler, resetConfigVariables, NULL, STD_LOADABLE_MODULE_ID));