summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2012-05-03 18:28:54 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2012-05-03 18:28:54 +0200
commit4f70113457993c536fc948d5b3b3e69dc7a92a8a (patch)
tree5682fe05ddeb53f20a28e02c3190185ce763cd8d
parent6e28d86c6a0a0c5788c5cb263b71aab19eb54cb5 (diff)
parentfe8ac119f75bc6d2763896b8e1a85ecfeb41bffb (diff)
downloadrsyslog-4f70113457993c536fc948d5b3b3e69dc7a92a8a.zip
rsyslog-4f70113457993c536fc948d5b3b3e69dc7a92a8a.tar.gz
rsyslog-4f70113457993c536fc948d5b3b3e69dc7a92a8a.tar.xz
Merge branch 'v5-stable' into v6-stable
Conflicts: ChangeLog configure.ac doc/manual.html
-rw-r--r--ChangeLog28
-rw-r--r--configure.ac16
-rw-r--r--doc/omudpspoof.html20
-rw-r--r--plugins/ommysql/ommysql.c20
-rw-r--r--runtime/queue.c54
-rw-r--r--tools/syslogd.c1
6 files changed, 120 insertions, 19 deletions
diff --git a/ChangeLog b/ChangeLog
index 77b8481..4d718d9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -15,6 +15,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
@@ -262,7 +272,19 @@ Version 5.9.0 [V5-DEVEL] (rgerhards), 2011-03-??
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
@@ -272,6 +294,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 ed68a11..3edc322 100644
--- a/configure.ac
+++ b/configure.ac
@@ -518,8 +518,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 16cb9b1..df14bbe 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> &lt;templatename&gt;<br>
+<li><b>$ActionOMOMUDPSpoofSourceNameTemplate</b> &lt;templatename&gt;<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> &lt;hostname&gt;<br>
Host that the messages shall be sent to.
-<li><b>$ActionUDPSpoofTargetPort</b> &lt;port&gt;<br>
+<li><b>$ActionOMUDPSpoofTargetPort</b> &lt;port&gt;<br>
Remote port that the messages shall be sent to.
<li><b>$ActionOMUDPSpoofDefaultTemplate</b> &lt;templatename&gt;<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
*.*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :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
*.*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :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
*.*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :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 &copy; 2009 by <a href="http://www.gerhards.net/rainer">Rainer Gerhards</a> and
+Copyright &copy; 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 41c8be6..79fd1b9 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));
diff --git a/runtime/queue.c b/runtime/queue.c
index 9f31852..e968806 100644
--- a/runtime/queue.c
+++ b/runtime/queue.c
@@ -1715,7 +1715,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,
@@ -1768,7 +1768,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);
@@ -1847,7 +1847,6 @@ qqueueStart(qqueue_t *pThis) /* this is the ConstructionFinalizer */
int wrk;
uchar *qName;
size_t lenBuf;
- int iQueueSizeSave;
ASSERT(pThis != NULL);
@@ -2245,8 +2244,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)
*/
@@ -2273,15 +2277,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);
+
+ }
}
}
@@ -2294,6 +2331,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!
diff --git a/tools/syslogd.c b/tools/syslogd.c
index 6ee4803..9f8c88f 100644
--- a/tools/syslogd.c
+++ b/tools/syslogd.c
@@ -1486,6 +1486,7 @@ runInputModules(void)
pMod = module.GetNxtType(NULL, eMOD_IN);
while(pMod != NULL) {
if(pMod->mod.im.bCanRun) {
+ DBGPRINTF("trying to start input module '%s'\n", pMod->pszName);
/* activate here */
bNeedsCancel = (pMod->isCompatibleWithFeature(sFEATURENonCancelInputTermination) == RS_RET_OK) ?
0 : 1;