From a34e46801b52b2614f9f3f16eb23e6fd14de6288 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 3 May 2012 12:32:03 +0200 Subject: 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). --- ChangeLog | 5 +++++ plugins/ommysql/ommysql.c | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) 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)); -- cgit