diff options
Diffstat (limited to 'plugins/ommysql/ommysql.c')
-rw-r--r-- | plugins/ommysql/ommysql.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/plugins/ommysql/ommysql.c b/plugins/ommysql/ommysql.c index 41c8be65..79fd1b9e 100644 --- a/plugins/ommysql/ommysql.c +++ b/plugins/ommysql/ommysql.c @@ -100,7 +100,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; } @@ -329,6 +328,11 @@ ENDparseSelectorAct BEGINmodExit CODESTARTmodExit +# ifdef HAVE_MYSQL_LIBRARY_INIT + mysql_library_end(); +# else + mysql_server_end(); +# endif ENDmodExit @@ -357,6 +361,20 @@ SCOPINGmodInit *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( +# ifdef HAVE_MYSQL_LIBRARY_INIT + mysql_library_init(0, NULL, NULL) +# else + mysql_server_init(0, NULL, NULL) +# endif + ) { + 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, &cs.iSrvPort, STD_LOADABLE_MODULE_ID)); CHKiRet(omsdRegCFSLineHdlr((uchar *)"ommysqlconfigfile",0,eCmdHdlrGetWord,NULL,&cs.pszMySQLConfigFile,STD_LOADABLE_MODULE_ID)); |