diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2012-05-03 18:33:29 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2012-05-03 18:33:29 +0200 |
commit | e53ef769dd5eaf6399d2dfc467a29d9295aa1d73 (patch) | |
tree | 53d60d77fb1419ba0a497aca842f2f884d164efd | |
parent | 99d9c6d52ced294dee2822d36ede069c2bd37044 (diff) | |
parent | 4f70113457993c536fc948d5b3b3e69dc7a92a8a (diff) | |
download | rsyslog-e53ef769dd5eaf6399d2dfc467a29d9295aa1d73.tar.gz rsyslog-e53ef769dd5eaf6399d2dfc467a29d9295aa1d73.tar.xz rsyslog-e53ef769dd5eaf6399d2dfc467a29d9295aa1d73.zip |
Merge branch 'v6-stable'
Conflicts:
tools/syslogd.c
-rw-r--r-- | ChangeLog | 38 | ||||
-rw-r--r-- | configure.ac | 16 | ||||
-rw-r--r-- | doc/omudpspoof.html | 20 | ||||
-rw-r--r-- | plugins/ommysql/ommysql.c | 20 | ||||
-rw-r--r-- | runtime/queue.c | 53 |
5 files changed, 129 insertions, 18 deletions
@@ -15,6 +15,16 @@ Version 6.3.9 [DEVEL] 2012-04-?? -bugfix/omfile: template action parameter was not accepted (and template name set to "??" if the parameter was used) Thanks to Brian Knox for alerting us on this bug. +- 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 + Thanks to Marcin M for bringing up this problem and Andre Lorbach + for helping to reproduce and fix it. --------------------------------------------------------------------------- Version 6.3.8 [DEVEL] 2012-04-16 - added $PStatJSON directive to permit stats records in JSON format @@ -159,6 +169,16 @@ Version 6.2.1 [v6-stable], 2012-01-?? - bugfix: stopped DA queue was never processed after a restart due to a regression from statistics module - bugfix: memory leak in array passing output module mode +- 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 + Thanks to Marcin M for bringing up this problem and Andre Lorbach + for helping to reproduce and fix it. --------------------------------------------------------------------------- Version 6.2.0 [v6-stable], 2012-01-09 - bugfix (kind of): removed numerical part from pri-text @@ -537,7 +557,19 @@ Version 5.9.0 [V5-DEVEL] (rgerhards), 2011-06-08 affected directive was: $ActionExecOnlyWhenPreviousIsSuspended on closes: http://bugzilla.adiscon.com/show_bug.cgi?id=236 --------------------------------------------------------------------------- -Version 5.8.11 [V5-stable] 2012-04-?? +Version 5.8.11 [V5-stable] 2012-05-03 +- 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 + Thanks to Marcin M for bringing up this problem and Andre Lorbach + for helping to reproduce and fix it. +- bugfix: active input in "light delay state" could block rsyslog + termination, at least for prolonged period of time - bugfix: imptcp input name could not be set config directive was accepted, but had no effect - bugfix: assigned ruleset was lost when using disk queues @@ -547,6 +579,10 @@ Version 5.8.11 [V5-stable] 2012-04-?? - bugfix: hostname was not requeried on HUP Thanks to Per Jessen for reporting this bug and Marius Tomaschewski for his help in testing the fix. +- bugfix: inside queue.c, some thread cancel states were not correctly + reset. While this is a bug, we assume it did have no practical effect + because the reset as it was done was set to the state the code actually + had at this point. But better fix this... --------------------------------------------------------------------------- Version 5.8.10 [V5-stable] 2012-04-05 - bugfix: segfault on startup if $actionqueuefilename was missing for disk diff --git a/configure.ac b/configure.ac index 94d43d85..d92804f7 100644 --- a/configure.ac +++ b/configure.ac @@ -517,8 +517,24 @@ if test "x$enable_mysql" = "xyes"; then [AC_MSG_FAILURE([MySQL library is missing])], [`mysql_config --libs`] ) + AC_MSG_CHECKING(if we have mysql_library_init) + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $MYSQL_CFLAGS" + save_LIBS="$LIBS" + LIBS="$LIBS $MYSQL_LIBS" + AC_TRY_LINK( + [#include <mysql.h> + #include <stdio.h>], + [mysql_library_init(0, NULL, NULL)], + [have_mysql_library_init=yes], + [have_mysql_library_init=no]) + CFLAGS="$save_CFLAGS" + LIBS="$save_LIBS" fi AM_CONDITIONAL(ENABLE_MYSQL, test x$enable_mysql = xyes) +if test "$have_mysql_library_init" = "yes"; then + AC_DEFINE([HAVE_MYSQL_LIBRARY_INIT], [1], [mysql_library_init available]) +fi AC_SUBST(MYSQL_CFLAGS) AC_SUBST(MYSQL_LIBS) diff --git a/doc/omudpspoof.html b/doc/omudpspoof.html index 16cb9b13..df14bbe1 100644 --- a/doc/omudpspoof.html +++ b/doc/omudpspoof.html @@ -16,7 +16,7 @@ spoof the sender address. Also, it enables to circle through a number of source ports. <p><b>Configuration Directives</b>:</p> <ul> -<li><b>$ActionOMUDPSpoofSourceNameTemplate</b> <templatename><br> +<li><b>$ActionOMOMUDPSpoofSourceNameTemplate</b> <templatename><br> This is the name of the template that contains a numerical IP address that is to be used as the source system IP address. While it may often be a constant value, it can be generated as usual via the @@ -28,7 +28,7 @@ So in essence, the default template spoofs the address of the system the message was received from. This is considered the most important use case. <li><b>$ActionOMUDPSpoofTargetHost</b> <hostname><br> Host that the messages shall be sent to. -<li><b>$ActionUDPSpoofTargetPort</b> <port><br> +<li><b>$ActionOMUDPSpoofTargetPort</b> <port><br> Remote port that the messages shall be sent to. <li><b>$ActionOMUDPSpoofDefaultTemplate</b> <templatename><br> This setting instructs omudpspoof to use a template different from the @@ -53,7 +53,7 @@ care about the source port. This example is considered the typical use case for omudpspoof. </p> <textarea rows="5" cols="80">$ModLoad omudpspoof -$ActionUDPSpoofTargetHost server.example.com +$ActionOMUDPSpoofTargetHost server.example.com *.* :omudpspoof: </textarea> @@ -64,10 +64,10 @@ source port 514 is used. <textarea rows="8" cols="80">$ModLoad omudpspoof $template spoofaddr,"192.0.2.1" $template spooftemplate,"%rawmsg%" -$ActionUDPSpoofSourceNameTemplate spoofaddr -$ActionUDPSpoofTargetHost server.example.com -$ActionUDPSpoofSourcePortStart 514 -$ActionUDPSpoofSourcePortEnd 514 +$ActionOMUDPSpoofSourceNameTemplate spoofaddr +$ActionOMUDPSpoofTargetHost server.example.com +$ActionOMUDPSpoofSourcePortStart 514 +$ActionOMUDPSpoofSourcePortEnd 514 *.* :omudpspoof:;spooftemplate </textarea> <p>The following sample is similar to the previous, but uses as many defaults as possible. @@ -77,8 +77,8 @@ have been changed, the previously set defaults will be used! </p> <textarea rows="5" cols="80">$ModLoad omudpspoof $template spoofaddr,"192.0.2.1" -$ActionUDPSpoofSourceNameTemplate spoofaddr -$ActionUDPSpoofTargetHost server.example.com +$ActionOMUDPSpoofSourceNameTemplate spoofaddr +$ActionOMUDPSpoofTargetHost server.example.com *.* :omudpspoof: </textarea> <p>[<a href="rsyslog_conf.html">rsyslog.conf overview</a>] @@ -86,7 +86,7 @@ $ActionUDPSpoofTargetHost server.example.com <p><font size="2">This documentation is part of the <a href="http://www.rsyslog.com/">rsyslog</a> project.<br> -Copyright © 2009 by <a href="http://www.gerhards.net/rainer">Rainer Gerhards</a> and +Copyright © 2009-2012 by <a href="http://www.gerhards.net/rainer">Rainer Gerhards</a> and <a href="http://www.adiscon.com/">Adiscon</a>. Released under the GNU GPL version 3 or higher.</font></p> </body></html> diff --git a/plugins/ommysql/ommysql.c b/plugins/ommysql/ommysql.c index 32d4d73a..253fc4c0 100644 --- a/plugins/ommysql/ommysql.c +++ b/plugins/ommysql/ommysql.c @@ -120,7 +120,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; } @@ -426,6 +425,11 @@ ENDparseSelectorAct BEGINmodExit CODESTARTmodExit +# ifdef HAVE_MYSQL_LIBRARY_INIT + mysql_library_end(); +# else + mysql_server_end(); +# endif ENDmodExit @@ -455,6 +459,20 @@ INITLegCnfVars *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)); diff --git a/runtime/queue.c b/runtime/queue.c index 7085c829..e08f3936 100644 --- a/runtime/queue.c +++ b/runtime/queue.c @@ -1801,7 +1801,7 @@ ConsumerReg(qqueue_t *pThis, wti_t *pWti) } /* but now cancellation is no longer permitted */ - pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &iCancelStateSave); + pthread_setcancelstate(iCancelStateSave, NULL); finalize_it: DBGPRINTF("regular consumer finished, iret=%d, szlog %d sz phys %d\n", iRet, @@ -1854,7 +1854,7 @@ ConsumerDA(qqueue_t *pThis, wti_t *pWti) } /* but now cancellation is no longer permitted */ - pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &iCancelStateSave); + pthread_setcancelstate(iCancelStateSave, NULL); /* now we are done, but need to re-aquire the mutex */ d_pthread_mutex_lock(pThis->mut); @@ -2383,8 +2383,13 @@ static inline rsRetVal doEnqSingleObj(qqueue_t *pThis, flowControl_t flowCtlType, void *pUsr) { DEFiRet; + int err; struct timespec t; + if(glbl.GetGlobalInputTermState()) { + ABORT_FINALIZE(RS_RET_FORCE_TERM); + } + STATSCOUNTER_INC(pThis->ctrEnqueued, pThis->mutCtrEnqueued); /* first check if we need to discard this message (which will cause CHKiRet() to exit) */ @@ -2411,15 +2416,48 @@ doEnqSingleObj(qqueue_t *pThis, flowControl_t flowCtlType, void *pUsr) * It's a side effect, but a good one ;) -- rgerhards, 2008-03-14 */ if(flowCtlType == eFLOWCTL_FULL_DELAY) { + DBGOPRINT((obj_t*) pThis, "enqueueMsg: FullDelay mark reached for full delayable message " + "- blocking.\n"); while(pThis->iQueueSize >= pThis->iFullDlyMrk) { - DBGOPRINT((obj_t*) pThis, "enqueueMsg: FullDelay mark reached for full delayable message - blocking.\n"); - pthread_cond_wait(&pThis->belowFullDlyWtrMrk, pThis->mut); /* TODO error check? But what do then? */ + /* We have a problem during shutdown if we block eternally. In that + * case, the the input thread cannot be terminated. So we wake up + * from time to time to check for termination. + * TODO/v6(at earliest): check if we could signal the condition during + * shutdown. However, this requires new queue registries and thus is + * far to much change for a stable version (and I am still not sure it + * is worth the effort, given how seldom this situation occurs and how + * few resources the wakeups need). -- rgerhards, 2012-05-03 + * In any case, this was the old code (if we do the TODO): + * pthread_cond_wait(&pThis->belowFullDlyWtrMrk, pThis->mut); + */ + timeoutComp(&t, 1000); + err = pthread_cond_timedwait(&pThis->belowLightDlyWtrMrk, pThis->mut, &t); + if(err != 0 && err != ETIMEDOUT) { + /* Something is really wrong now. Report to debug log and abort the + * wait. That keeps us running, even though we may lose messages. + */ + DBGOPRINT((obj_t*) pThis, "potential program bug: pthread_cond_timedwait()" + "/fulldelay returned %d\n", err); + break; + + } + DBGPRINTF("wti worker in full delay timed out, checking termination...\n"); + if(glbl.GetGlobalInputTermState()) { + ABORT_FINALIZE(RS_RET_FORCE_TERM); + } } } else if(flowCtlType == eFLOWCTL_LIGHT_DELAY) { if(pThis->iQueueSize >= pThis->iLightDlyMrk) { - DBGOPRINT((obj_t*) pThis, "enqueueMsg: LightDelay mark reached for light delayable message - blocking a bit.\n"); + DBGOPRINT((obj_t*) pThis, "enqueueMsg: LightDelay mark reached for light " + "delayable message - blocking a bit.\n"); timeoutComp(&t, 1000); /* 1000 millisconds = 1 second TODO: make configurable */ - pthread_cond_timedwait(&pThis->belowLightDlyWtrMrk, pThis->mut, &t); /* TODO error check? But what do then? */ + err = pthread_cond_timedwait(&pThis->belowLightDlyWtrMrk, pThis->mut, &t); + if(err != 0 && err != ETIMEDOUT) { + /* Something is really wrong now. Report to debug log */ + DBGOPRINT((obj_t*) pThis, "potential program bug: pthread_cond_timedwait()" + "/lightdelay returned %d\n", err); + + } } } @@ -2432,6 +2470,9 @@ doEnqSingleObj(qqueue_t *pThis, flowControl_t flowCtlType, void *pUsr) || (pThis->qType == QUEUETYPE_DISK && pThis->sizeOnDiskMax != 0 && pThis->tVars.disk.sizeOnDisk > pThis->sizeOnDiskMax)) { DBGOPRINT((obj_t*) pThis, "enqueueMsg: queue FULL - waiting to drain.\n"); + if(glbl.GetGlobalInputTermState()) { + ABORT_FINALIZE(RS_RET_FORCE_TERM); + } timeoutComp(&t, pThis->toEnq); STATSCOUNTER_INC(pThis->ctrFull, pThis->mutCtrFull); // TODO : handle enqOnly => discard! |