summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog15
-rw-r--r--grammar/rainerscript.c9
-rw-r--r--plugins/imtcp/imtcp.c4
-rw-r--r--runtime/glbl.c43
-rw-r--r--runtime/msg.c17
5 files changed, 62 insertions, 26 deletions
diff --git a/ChangeLog b/ChangeLog
index 6575b112..dab45f08 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -187,6 +187,17 @@ Version 7.5.0 [devel] 2013-06-11
Thanks to Axel Rau for the patch.
---------------------------------------------------------------------------
Version 7.4.6 [v7.4-stable] 2013-11-??
+- bugfix: potential abort during HUP
+ This could happen when one of imklog, imzmq3, imkmsg, impstats,
+ imjournal, or imuxsock were under heavy load during a HUP.
+ closes: http://bugzilla.adiscon.com/show_bug.cgi?id=489
+ Thanks to Guy Rozendorn for reporting the problem and Peval Levhshin for
+ his analysis.
+- bugfix: imtcp flowControl parameter incorrectly defaulted to "off"
+ This could cause message loss on systems under heavy load and was
+ a change-of-behaviour to previous version. This is a regression
+ most probably introduced in 5.9.0 (but did not try hard to find the
+ exact point of its introduction).
- now requires libestr 0.1.9 as earlier versions lead to problems with
number handling in RainerScript
- bugfix: memory leak in strlen() RainerScript function
@@ -196,6 +207,10 @@ Version 7.4.6 [v7.4-stable] 2013-11-??
Thanks to Pavel Levshin for reporting the problem and its location.
- bugfix: memleak in re_extract() function
Thanks to Pavel Levshin for reporting this problem.
+- bugfix: potential abort in RainerScript optimizer
+ closes: http://bugzilla.adiscon.com/show_bug.cgi?id=488
+ Thanks to Thomas Doll for reporting the problem and Pavel Levshin for
+ fixing it.
- bugfix: memory leak in omhiredis
Thanks to Pavel Levshin for the fix
- bugfix: segfault if variable was assigned to non-container subtree
diff --git a/grammar/rainerscript.c b/grammar/rainerscript.c
index abf9dd34..fcc3ed6f 100644
--- a/grammar/rainerscript.c
+++ b/grammar/rainerscript.c
@@ -3068,12 +3068,15 @@ cnfexprOptimize(struct cnfexpr *expr)
expr->r = exprswap;
}
}
- if(expr->l->nodetype == 'V') {
- expr = cnfexprOptimize_CMP_var(expr);
- }
if(expr->r->nodetype == 'A') {
cnfexprOptimize_CMPEQ_arr((struct cnfarray *)expr->r);
}
+ /* This should be evaluated last because it may change expr
+ * to a function.
+ */
+ if(expr->l->nodetype == 'V') {
+ expr = cnfexprOptimize_CMP_var(expr);
+ }
break;
case CMP_LE:
case CMP_GE:
diff --git a/plugins/imtcp/imtcp.c b/plugins/imtcp/imtcp.c
index 4df02ef0..51697574 100644
--- a/plugins/imtcp/imtcp.c
+++ b/plugins/imtcp/imtcp.c
@@ -419,7 +419,7 @@ CODESTARTbeginCnfLoad
loadModConf->iTCPLstnMax = 20;
loadModConf->bSuppOctetFram = 1;
loadModConf->iStrmDrvrMode = 0;
- loadModConf->bUseFlowControl = 0;
+ loadModConf->bUseFlowControl = 1;
loadModConf->bKeepAlive = 0;
loadModConf->bEmitMsgOnClose = 0;
loadModConf->iAddtlFrameDelim = TCPSRV_NO_ADDTL_DELIMITER;
@@ -647,7 +647,7 @@ resetConfigVariables(uchar __attribute__((unused)) *pp, void __attribute__((unus
cs.iTCPLstnMax = 20;
cs.bSuppOctetFram = 1;
cs.iStrmDrvrMode = 0;
- cs.bUseFlowControl = 0;
+ cs.bUseFlowControl = 1;
cs.bKeepAlive = 0;
cs.bEmitMsgOnClose = 0;
cs.iAddtlFrameDelim = TCPSRV_NO_ADDTL_DELIMITER;
diff --git a/runtime/glbl.c b/runtime/glbl.c
index cbb9b20f..17ae0451 100644
--- a/runtime/glbl.c
+++ b/runtime/glbl.c
@@ -32,6 +32,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
+#include <pthread.h>
#include <assert.h>
#include "rsyslog.h"
@@ -72,6 +73,7 @@ static int option_DisallowWarning = 1; /* complain if message from disallowed se
static int bDisableDNS = 0; /* don't look up IP addresses of remote messages */
static prop_t *propLocalIPIF = NULL;/* IP address to report for the local host (default is 127.0.0.1) */
static prop_t *propLocalHostName = NULL;/* our hostname as FQDN - read-only after startup */
+static prop_t *propLocalHostNameToDelete = NULL;/* see GenerateLocalHostName function hdr comment! */
static uchar *LocalHostName = NULL;/* our hostname - read-only after startup, except HUP */
static uchar *LocalHostNameOverride = NULL;/* user-overridden hostname - read-only after startup */
static uchar *LocalFQDNName = NULL;/* our hostname as FQDN - read-only after startup, except HUP */
@@ -382,17 +384,31 @@ GetLocalDomain(void)
/* generate the local hostname property. This must be done after the hostname info
* has been set as well as PreserveFQDN.
* rgerhards, 2009-06-30
+ * NOTE: This function tries to avoid locking by not destructing the previous value
+ * immediately. This is so that current readers can continue to use the previous name.
+ * Otherwise, we would need to use read/write locks to protect the update process.
+ * In order to do so, we save the previous value and delete it when we are called again
+ * the next time. Note that this in theory is racy and can lead to a double-free.
+ * In practice, however, the window of exposure to trigger this is extremely short
+ * and as this functions is very infrequently being called (on HUP), the trigger
+ * condition for this bug is so highly unlikely that it never occurs in practice.
+ * Probably if you HUP rsyslog every few milliseconds, but who does that...
+ * To further reduce risk potential, we do only update the property when there
+ * actually is a hostname change, which makes it even less likely.
+ * rgerhards, 2013-10-28
*/
static rsRetVal
GenerateLocalHostNameProperty(void)
{
- DEFiRet;
+ uchar *pszPrev;
+ int lenPrev;
+ prop_t *hostnameNew;
uchar *pszName;
+ DEFiRet;
- if(propLocalHostName != NULL)
- prop.Destruct(&propLocalHostName);
+ if(propLocalHostNameToDelete != NULL)
+ prop.Destruct(&propLocalHostNameToDelete);
- CHKiRet(prop.Construct(&propLocalHostName));
if(LocalHostNameOverride == NULL) {
if(LocalHostName == NULL)
pszName = (uchar*) "[localhost]";
@@ -406,8 +422,20 @@ GenerateLocalHostNameProperty(void)
pszName = LocalHostNameOverride;
}
DBGPRINTF("GenerateLocalHostName uses '%s'\n", pszName);
- CHKiRet(prop.SetString(propLocalHostName, pszName, ustrlen(pszName)));
- CHKiRet(prop.ConstructFinalize(propLocalHostName));
+
+ if(propLocalHostName == NULL)
+ pszPrev = (uchar*)""; /* make sure strcmp() below does not match */
+ else
+ prop.GetString(propLocalHostName, &pszPrev, &lenPrev);
+
+ if(ustrcmp(pszPrev, pszName)) {
+ /* we need to update */
+ CHKiRet(prop.Construct(&hostnameNew));
+ CHKiRet(prop.SetString(hostnameNew, pszName, ustrlen(pszName)));
+ CHKiRet(prop.ConstructFinalize(hostnameNew));
+ propLocalHostNameToDelete = propLocalHostName;
+ propLocalHostName = hostnameNew;
+ }
finalize_it:
RETiRet;
@@ -419,6 +447,7 @@ finalize_it:
static prop_t*
GetLocalHostNameProp(void)
{
+ prop.AddRef(propLocalHostName);
return(propLocalHostName);
}
@@ -720,6 +749,8 @@ BEGINObjClassExit(glbl, OBJ_IS_CORE_MODULE) /* class, version */
free(LocalHostNameOverride);
free(LocalFQDNName);
objRelease(prop, CORE_COMPONENT);
+ if(propLocalHostNameToDelete != NULL)
+ prop.Destruct(&propLocalHostNameToDelete);
DESTROY_ATOMIC_HELPER_MUT(mutTerminateInputs);
ENDObjClassExit(glbl)
diff --git a/runtime/msg.c b/runtime/msg.c
index 907000c4..21ab18e5 100644
--- a/runtime/msg.c
+++ b/runtime/msg.c
@@ -359,7 +359,7 @@ MsgSetRcvFromIPWithoutAddRef(msg_t *pThis, prop_t *new)
/* set RcvFrom name in msg object WITHOUT calling AddRef.
* rgerhards, 2013-01-22
*/
-void MsgSetRcvFromWithoutAddRef(msg_t *pThis, prop_t *new)
+void MsgSetRcvFrom(msg_t *pThis, prop_t *new)
{
assert(pThis != NULL);
@@ -401,7 +401,7 @@ resolveDNS(msg_t *pMsg) {
localRet = net.cvthname(pMsg->rcvFrom.pfrominet, &localName, NULL, &ip);
if(localRet == RS_RET_OK) {
/* we pass down the props, so no need for AddRef */
- MsgSetRcvFromWithoutAddRef(pMsg, localName);
+ MsgSetRcvFrom(pMsg, localName);
MsgSetRcvFromIPWithoutAddRef(pMsg, ip);
}
}
@@ -2244,19 +2244,6 @@ finalize_it:
RETiRet;
}
-
-/* rgerhards 2008-09-10: set RcvFrom name in msg object. This calls AddRef()
- * on the property, because this must be done in all current cases and there
- * is no case expected where this may not be necessary.
- * rgerhards, 2009-06-30
- */
-void MsgSetRcvFrom(msg_t *pThis, prop_t *new)
-{
- prop.AddRef(new);
- MsgSetRcvFromWithoutAddRef(pThis, new);
-}
-
-
/* This is used to set the property via a string. This function should not be
* called if there is a reliable way for a caller to make sure that the
* same name can be used across multiple messages. However, if it can not