summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/cfsysline.c21
-rw-r--r--runtime/debug.c4
-rw-r--r--runtime/debug.h1
-rw-r--r--runtime/modules.c31
-rw-r--r--runtime/msg.c131
-rw-r--r--runtime/obj.c4
-rw-r--r--runtime/obj.h4
-rw-r--r--runtime/queue.c69
-rw-r--r--runtime/rsconf.c4
-rw-r--r--runtime/srUtils.h13
10 files changed, 158 insertions, 124 deletions
diff --git a/runtime/cfsysline.c b/runtime/cfsysline.c
index af88b3de..fdbb8f2a 100644
--- a/runtime/cfsysline.c
+++ b/runtime/cfsysline.c
@@ -346,11 +346,12 @@ static int doParseOnOffOption(uchar **pp)
*/
static rsRetVal doGetGID(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void *pVal)
{
- struct group *pgBuf;
+ struct group *pgBuf = NULL;
struct group gBuf;
DEFiRet;
uchar szName[256];
- char stringBuf[2048]; /* I hope this is large enough... */
+ int bufSize = 2048;
+ char * stringBuf = NULL;
assert(pp != NULL);
assert(*pp != NULL);
@@ -360,7 +361,17 @@ static rsRetVal doGetGID(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void *p
ABORT_FINALIZE(RS_RET_NOT_FOUND);
}
- getgrnam_r((char*)szName, &gBuf, stringBuf, sizeof(stringBuf), &pgBuf);
+
+ CHKmalloc(stringBuf = malloc(bufSize));
+ while(pgBuf == NULL) {
+ errno = 0;
+ getgrnam_r((char*)szName, &gBuf, stringBuf, bufSize, &pgBuf);
+ if((pgBuf == NULL) && (errno == ERANGE)) {
+ /* Increase bufsize and try again.*/
+ bufSize *= 2;
+ CHKmalloc(stringBuf = realloc(stringBuf, bufSize));
+ }
+ }
if(pgBuf == NULL) {
errmsg.LogError(0, RS_RET_NOT_FOUND, "ID for group '%s' could not be found or error", (char*)szName);
@@ -379,6 +390,7 @@ static rsRetVal doGetGID(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void *p
skipWhiteSpace(pp); /* skip over any whitespace */
finalize_it:
+ free(stringBuf);
RETiRet;
}
@@ -935,7 +947,8 @@ rsRetVal processCfSysLineCommand(uchar *pCmdName, uchar **p)
iRet = llFind(&llCmdList, (void *) pCmdName, (void*) &pCmd);
if(iRet == RS_RET_NOT_FOUND) {
- errmsg.LogError(0, RS_RET_NOT_FOUND, "invalid or yet-unknown config file command - have you forgotten to load a module?");
+ errmsg.LogError(0, RS_RET_NOT_FOUND, "invalid or yet-unknown config file command '%s' - "
+ "have you forgotten to load a module?", pCmdName);
}
if(iRet != RS_RET_OK)
diff --git a/runtime/debug.c b/runtime/debug.c
index 955076e2..edc4a255 100644
--- a/runtime/debug.c
+++ b/runtime/debug.c
@@ -68,7 +68,7 @@ static int bPrintAllDebugOnExit = 0;
static int bAbortTrace = 1; /* print a trace after SIGABRT or SIGSEGV */
static char *pszAltDbgFileName = NULL; /* if set, debug output is *also* sent to here */
static int altdbg = -1; /* and the handle for alternate debug output */
-static int stddbg;
+int stddbg = 1; /* the handle for regular debug output, set to stdout if not forking, -1 otherwise */
/* list of files/objects that should be printed */
typedef struct dbgPrintName_s {
@@ -1303,8 +1303,6 @@ dbgGetRuntimeOptions(void)
uchar *optname;
/* set some defaults */
- stddbg = 1;
-
if((pszOpts = (uchar*) getenv("RSYSLOG_DEBUG")) != NULL) {
/* we have options set, so let's process them */
while(dbgGetRTOptNamVal(&pszOpts, &optname, &optval)) {
diff --git a/runtime/debug.h b/runtime/debug.h
index 717c0fef..26672c3e 100644
--- a/runtime/debug.h
+++ b/runtime/debug.h
@@ -35,6 +35,7 @@
/* external static data elements (some time to be replaced) */
extern int Debug; /* debug flag - read-only after startup */
extern int debugging_on; /* read-only, except on sig USR1 */
+extern int stddbg; /* the handle for regular debug output, set to stdout if not forking, -1 otherwise */
/* data types */
diff --git a/runtime/modules.c b/runtime/modules.c
index 5a87c8be..dac3bd95 100644
--- a/runtime/modules.c
+++ b/runtime/modules.c
@@ -67,14 +67,6 @@ DEFobjCurrIf(errmsg)
DEFobjCurrIf(parser)
DEFobjCurrIf(strgen)
-/* we must ensure that only one thread at one time tries to load or unload
- * modules, otherwise we may see race conditions. This first came up with
- * imdiag/imtcp, which both use the same stream drivers. Below is the mutex
- * for that handling.
- * rgerhards, 2009-05-25
- */
-static pthread_mutex_t mutLoadUnload;
-
static modInfo_t *pLoadedModules = NULL; /* list of currently-loaded modules */
static modInfo_t *pLoadedModulesLast = NULL; /* tail-pointer */
@@ -819,7 +811,7 @@ modUnlinkAndDestroy(modInfo_t **ppThis)
pThis = *ppThis;
assert(pThis != NULL);
- pthread_mutex_lock(&mutLoadUnload);
+ pthread_mutex_lock(&mutObjGlobalOp);
/* first check if we are permitted to unload */
if(pThis->eType == eMOD_LIB) {
@@ -855,7 +847,7 @@ modUnlinkAndDestroy(modInfo_t **ppThis)
moduleDestruct(pThis);
finalize_it:
- pthread_mutex_unlock(&mutLoadUnload);
+ pthread_mutex_unlock(&mutObjGlobalOp);
RETiRet;
}
@@ -970,7 +962,7 @@ Load(uchar *pModName, sbool bConfLoad)
*/
# define PATHBUF_OVERHEAD 1 + iModNameLen + 3 + 1
- pthread_mutex_lock(&mutLoadUnload);
+ pthread_mutex_lock(&mutObjGlobalOp);
if(iModNameLen > 3 && !strcmp((char *) pModName + iModNameLen - 3, ".so")) {
iModNameLen -= 3;
@@ -1096,7 +1088,7 @@ Load(uchar *pModName, sbool bConfLoad)
finalize_it:
if(pPathBuf != pathBuf) /* used malloc()ed memory? */
free(pPathBuf);
- pthread_mutex_unlock(&mutLoadUnload);
+ pthread_mutex_unlock(&mutObjGlobalOp);
RETiRet;
}
@@ -1193,16 +1185,6 @@ CODESTARTObjClassExit(module)
/* release objects we no longer need */
objRelease(errmsg, CORE_COMPONENT);
objRelease(parser, CORE_COMPONENT);
- /* We have a problem in our reference counting, which leads to this function
- * being called too early. This usually is no problem, but if we destroy
- * the mutex object, we get into trouble. So rather than finding the root cause,
- * we do not release the mutex right now and have a very, very slight leak.
- * We know that otherwise no bad effects happen, so this acceptable for the
- * time being. -- rgerhards, 2009-05-25
- *
- * TODO: add again: pthread_mutex_destroy(&mutLoadUnload);
- */
-
free(pModDir);
# ifdef DEBUG
modUsrPrintAll(); /* debug aid - TODO: integrate with debug.c, at least the settings! */
@@ -1246,7 +1228,6 @@ ENDobjQueryInterface(module)
*/
BEGINAbstractObjClassInit(module, 1, OBJ_IS_CORE_MODULE) /* class, version - CHANGE class also in END MACRO! */
uchar *pModPath;
- pthread_mutexattr_t mutAttr;
/* use any module load path specified in the environment */
if((pModPath = (uchar*) getenv("RSYSLOG_MODDIR")) != NULL) {
@@ -1264,10 +1245,6 @@ BEGINAbstractObjClassInit(module, 1, OBJ_IS_CORE_MODULE) /* class, version - CHA
SetModDir(glblModPath);
}
- pthread_mutexattr_init(&mutAttr);
- pthread_mutexattr_settype(&mutAttr, PTHREAD_MUTEX_RECURSIVE);
- pthread_mutex_init(&mutLoadUnload, &mutAttr);
-
/* request objects we use */
CHKiRet(objUse(errmsg, CORE_COMPONENT));
ENDObjClassInit(module)
diff --git a/runtime/msg.c b/runtime/msg.c
index d35e92a7..a7df6928 100644
--- a/runtime/msg.c
+++ b/runtime/msg.c
@@ -1004,11 +1004,15 @@ msg_t* MsgDup(msg_t* pOld)
} else {
tmpCOPYSZ(RawMsg);
}
- if(pOld->iLenHOSTNAME < CONF_HOSTNAME_BUFSIZE) {
- memcpy(pNew->szHOSTNAME, pOld->szHOSTNAME, pOld->iLenHOSTNAME + 1);
- pNew->pszHOSTNAME = pNew->szHOSTNAME;
+ if(pOld->pszHOSTNAME == NULL) {
+ pNew->pszHOSTNAME = NULL;
} else {
- tmpCOPYSZ(HOSTNAME);
+ if(pOld->iLenHOSTNAME < CONF_HOSTNAME_BUFSIZE) {
+ memcpy(pNew->szHOSTNAME, pOld->szHOSTNAME, pOld->iLenHOSTNAME + 1);
+ pNew->pszHOSTNAME = pNew->szHOSTNAME;
+ } else {
+ tmpCOPYSZ(HOSTNAME);
+ }
}
tmpCOPYCSTR(ProgName);
@@ -1638,7 +1642,7 @@ char *getPROCID(msg_t *pM, sbool bLockMutex)
MsgLock(pM);
preparePROCID(pM, MUTEX_ALREADY_LOCKED);
if(pM->pCSPROCID == NULL)
- pszRet = UCHAR_CONSTANT("");
+ pszRet = UCHAR_CONSTANT("-");
else
pszRet = rsCStrGetSzStrNoNULL(pM->pCSPROCID);
if(bLockMutex == LOCK_MUTEX)
@@ -2749,6 +2753,10 @@ uchar *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe,
*pbMustBeFreed = 0;
break;
case PROP_SYS_UPTIME:
+# ifdef OS_SOLARIS
+ pRes = (uchar*) "UPTIME NOT available under Solaris";
+ *pbMustBeFreed = 0;
+# else
{
struct sysinfo s_info;
@@ -2764,6 +2772,7 @@ uchar *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe,
snprintf((char*) pRes, sizeof(uchar) * 32, "%ld", s_info.uptime);
}
+# endif
break;
default:
/* there is no point in continuing, we may even otherwise render the
@@ -2799,7 +2808,7 @@ uchar *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe,
*/
iCurrFld = 1;
pFld = pRes;
- while(*pFld && iCurrFld < pTpe->data.field.iToPos) {
+ while(*pFld && iCurrFld < pTpe->data.field.iFieldNr) {
/* skip fields until the requested field or end of string is found */
while(*pFld && (uchar) *pFld != pTpe->data.field.field_delim)
++pFld; /* skip to field terminator */
@@ -2813,9 +2822,9 @@ uchar *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe,
++iCurrFld;
}
}
- dbgprintf("field requested %d, field found %d\n", pTpe->data.field.iToPos, (int) iCurrFld);
+ dbgprintf("field requested %d, field found %d\n", pTpe->data.field.iFieldNr, (int) iCurrFld);
- if(iCurrFld == pTpe->data.field.iToPos) {
+ if(iCurrFld == pTpe->data.field.iFieldNr) {
/* field found, now extract it */
/* first of all, we need to find the end */
pFldEnd = pFld;
@@ -2850,58 +2859,6 @@ uchar *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe,
*pPropLen = sizeof("**FIELD NOT FOUND**") - 1;
return UCHAR_CONSTANT("**FIELD NOT FOUND**");
}
- } else if(pTpe->data.field.iFromPos != 0 || pTpe->data.field.iToPos != 0) {
- /* we need to obtain a private copy */
- int iFrom, iTo;
- uchar *pSb;
- iFrom = pTpe->data.field.iFromPos;
- iTo = pTpe->data.field.iToPos;
- /* need to zero-base to and from (they are 1-based!) */
- if(iFrom > 0)
- --iFrom;
- if(iTo > 0)
- --iTo;
- if(bufLen == -1)
- bufLen = ustrlen(pRes);
- if(iFrom == 0 && iTo >= bufLen) {
- /* in this case, the requested string is a superset of what we already have,
- * so there is no need to do any processing. This is a frequent case for size-limited
- * fields like TAG in the default forwarding template (so it is a useful optimization
- * to check for this condition ;)). -- rgerhards, 2009-07-09
- */
- ; /*DO NOTHING*/
- } else {
- iLen = iTo - iFrom + 1; /* the +1 is for an actual char, NOT \0! */
- pBufStart = pBuf = MALLOC((iLen + 1) * sizeof(char));
- if(pBuf == NULL) {
- if(*pbMustBeFreed == 1)
- free(pRes);
- RET_OUT_OF_MEMORY;
- }
- pSb = pRes;
- if(iFrom) {
- /* skip to the start of the substring (can't do pointer arithmetic
- * because the whole string might be smaller!!)
- */
- while(*pSb && iFrom) {
- --iFrom;
- ++pSb;
- }
- }
- /* OK, we are at the begin - now let's copy... */
- bufLen = iLen;
- while(*pSb && iLen) {
- *pBuf++ = *pSb;
- ++pSb;
- --iLen;
- }
- *pBuf = '\0';
- bufLen -= iLen; /* subtract remaining length if the string was smaller! */
- if(*pbMustBeFreed == 1)
- free(pRes);
- pRes = pBufStart;
- *pbMustBeFreed = 1;
- }
#ifdef FEATURE_REGEXP
} else {
/* Check for regular expressions */
@@ -3027,6 +2984,60 @@ uchar *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe,
#endif /* #ifdef FEATURE_REGEXP */
}
+ if(pTpe->data.field.iFromPos != 0 || pTpe->data.field.iToPos != 0) {
+ /* we need to obtain a private copy */
+ int iFrom, iTo;
+ uchar *pSb;
+ iFrom = pTpe->data.field.iFromPos;
+ iTo = pTpe->data.field.iToPos;
+ /* need to zero-base to and from (they are 1-based!) */
+ if(iFrom > 0)
+ --iFrom;
+ if(iTo > 0)
+ --iTo;
+ if(bufLen == -1)
+ bufLen = ustrlen(pRes);
+ if(iFrom == 0 && iTo >= bufLen) {
+ /* in this case, the requested string is a superset of what we already have,
+ * so there is no need to do any processing. This is a frequent case for size-limited
+ * fields like TAG in the default forwarding template (so it is a useful optimization
+ * to check for this condition ;)). -- rgerhards, 2009-07-09
+ */
+ ; /*DO NOTHING*/
+ } else {
+ iLen = iTo - iFrom + 1; /* the +1 is for an actual char, NOT \0! */
+ pBufStart = pBuf = MALLOC((iLen + 1) * sizeof(char));
+ if(pBuf == NULL) {
+ if(*pbMustBeFreed == 1)
+ free(pRes);
+ RET_OUT_OF_MEMORY;
+ }
+ pSb = pRes;
+ if(iFrom) {
+ /* skip to the start of the substring (can't do pointer arithmetic
+ * because the whole string might be smaller!!)
+ */
+ while(*pSb && iFrom) {
+ --iFrom;
+ ++pSb;
+ }
+ }
+ /* OK, we are at the begin - now let's copy... */
+ bufLen = iLen;
+ while(*pSb && iLen) {
+ *pBuf++ = *pSb;
+ ++pSb;
+ --iLen;
+ }
+ *pBuf = '\0';
+ bufLen -= iLen; /* subtract remaining length if the string was smaller! */
+ if(*pbMustBeFreed == 1)
+ free(pRes);
+ pRes = pBufStart;
+ *pbMustBeFreed = 1;
+ }
+ }
+
/* now check if we need to do our "SP if first char is non-space" hack logic */
if(*pRes && pTpe->data.field.options.bSPIffNo1stSP) {
/* here, we always destruct the buffer and return a new one */
diff --git a/runtime/obj.c b/runtime/obj.c
index 93fbd281..b2739c58 100644
--- a/runtime/obj.c
+++ b/runtime/obj.c
@@ -96,7 +96,7 @@ DEFobjCurrIf(module)
DEFobjCurrIf(errmsg)
DEFobjCurrIf(strm)
static objInfo_t *arrObjInfo[OBJ_NUM_IDS]; /* array with object information pointers */
-static pthread_mutex_t mutObjGlobalOp; /* mutex to guard global operations of the object system */
+pthread_mutex_t mutObjGlobalOp; /* mutex to guard global operations of the object system */
/* cookies for serialized lines */
@@ -1318,7 +1318,7 @@ objClassInit(modInfo_t *pModInfo)
}
/* the mutex must be recursive, because objects may call into other
- * object identifieres recursively.
+ * object identifiers recursively.
*/
pthread_mutexattr_init(&mutAttr);
pthread_mutexattr_settype(&mutAttr, PTHREAD_MUTEX_RECURSIVE);
diff --git a/runtime/obj.h b/runtime/obj.h
index be97f20e..32f7ef09 100644
--- a/runtime/obj.h
+++ b/runtime/obj.h
@@ -122,4 +122,8 @@ rsRetVal objGetObjInterface(obj_if_t *pIf);
PROTOTYPEObjClassInit(obj);
PROTOTYPEObjClassExit(obj);
+
+/* the following definition is only for "friends" */
+extern pthread_mutex_t mutObjGlobalOp; /* mutex to guard global operations of the object system */
+
#endif /* #ifndef OBJ_H_INCLUDED */
diff --git a/runtime/queue.c b/runtime/queue.c
index 7085c829..a2f80d29 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,6 +2383,7 @@ static inline rsRetVal
doEnqSingleObj(qqueue_t *pThis, flowControl_t flowCtlType, void *pUsr)
{
DEFiRet;
+ int err;
struct timespec t;
STATSCOUNTER_INC(pThis->ctrEnqueued, pThis->mutCtrEnqueued);
@@ -2411,15 +2412,45 @@ 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) {
- 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? */
+ while(pThis->iQueueSize >= pThis->iFullDlyMrk&& ! glbl.GetGlobalInputTermState()) {
+ /* 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);
+ */
+ DBGOPRINT((obj_t*) pThis, "enqueueMsg: FullDelay mark reached for full delayable message "
+ "- blocking, queue size is %d.\n", pThis->iQueueSize);
+ 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");
}
- } else if(flowCtlType == eFLOWCTL_LIGHT_DELAY) {
+ } else if(flowCtlType == eFLOWCTL_LIGHT_DELAY && !glbl.GetGlobalInputTermState()) {
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);
+
+ }
}
}
@@ -2431,17 +2462,27 @@ doEnqSingleObj(qqueue_t *pThis, flowControl_t flowCtlType, void *pUsr)
while( (pThis->iMaxQueueSize > 0 && pThis->iQueueSize >= pThis->iMaxQueueSize)
|| (pThis->qType == QUEUETYPE_DISK && pThis->sizeOnDiskMax != 0
&& pThis->tVars.disk.sizeOnDisk > pThis->sizeOnDiskMax)) {
- DBGOPRINT((obj_t*) pThis, "enqueueMsg: queue FULL - waiting to drain.\n");
- timeoutComp(&t, pThis->toEnq);
STATSCOUNTER_INC(pThis->ctrFull, pThis->mutCtrFull);
-// TODO : handle enqOnly => discard!
- if(pthread_cond_timedwait(&pThis->notFull, pThis->mut, &t) != 0) {
- DBGOPRINT((obj_t*) pThis, "enqueueMsg: cond timeout, dropping message!\n");
+ if(pThis->toEnq == 0 || pThis->bEnqOnly) {
+ DBGOPRINT((obj_t*) pThis, "enqueueMsg: queue FULL - configured for immediate discarding.\n");
STATSCOUNTER_INC(pThis->ctrFDscrd, pThis->mutCtrFDscrd);
objDestruct(pUsr);
ABORT_FINALIZE(RS_RET_QUEUE_FULL);
- }
+ } else {
+ DBGOPRINT((obj_t*) pThis, "enqueueMsg: queue FULL - waiting %dms to drain.\n", pThis->toEnq);
+ if(glbl.GetGlobalInputTermState()) {
+ DBGOPRINT((obj_t*) pThis, "enqueueMsg: queue FULL, discard due to FORCE_TERM.\n");
+ ABORT_FINALIZE(RS_RET_FORCE_TERM);
+ }
+ timeoutComp(&t, pThis->toEnq);
+ if(pthread_cond_timedwait(&pThis->notFull, pThis->mut, &t) != 0) {
+ DBGOPRINT((obj_t*) pThis, "enqueueMsg: cond timeout, dropping message!\n");
+ STATSCOUNTER_INC(pThis->ctrFDscrd, pThis->mutCtrFDscrd);
+ objDestruct(pUsr);
+ ABORT_FINALIZE(RS_RET_QUEUE_FULL);
+ }
dbgoprint((obj_t*) pThis, "enqueueMsg: wait solved queue full condition, enqueing\n");
+ }
}
/* and finally enqueue the message */
diff --git a/runtime/rsconf.c b/runtime/rsconf.c
index ff9e1291..16929b71 100644
--- a/runtime/rsconf.c
+++ b/runtime/rsconf.c
@@ -432,6 +432,7 @@ void cnfDoCfsysline(char *ln)
DBGPRINTF("cnf:global:cfsysline: %s\n", ln);
/* the legacy system needs the "$" stripped */
conf.cfsysline((uchar*) ln+1);
+ free(ln);
}
void cnfDoBSDTag(char *ln)
@@ -688,7 +689,8 @@ runInputModules(void)
DBGPRINTF("running module %s with config %p\n", node->pMod->pszName, node);
bNeedsCancel = (node->pMod->isCompatibleWithFeature(sFEATURENonCancelInputTermination) == RS_RET_OK) ?
0 : 1;
- thrdCreate(node->pMod->mod.im.runInput, node->pMod->mod.im.afterRun, bNeedsCancel);
+ thrdCreate(node->pMod->mod.im.runInput, node->pMod->mod.im.afterRun, bNeedsCancel,
+ (node->pMod->cnfName == NULL) ? node->pMod->pszName : node->pMod->cnfName);
}
node = module.GetNxtCnfType(runConf, node, eMOD_IN);
}
diff --git a/runtime/srUtils.h b/runtime/srUtils.h
index 76d25eb2..3169fd94 100644
--- a/runtime/srUtils.h
+++ b/runtime/srUtils.h
@@ -93,19 +93,6 @@ int getSubString(uchar **ppSrc, char *pDst, size_t DstSize, char cSep);
rsRetVal getFileSize(uchar *pszName, off_t *pSize);
/* mutex operations */
-/* some macros to cancel-safe lock a mutex (it will automatically be released
- * when the thread is cancelled. This needs to be done as macros because
- * pthread_cleanup_push sometimes is a macro that can not be used inside a function.
- * It's a bit ugly, but works well... rgerhards, 2008-01-20
- */
-#define DEFVARS_mutex_cancelsafeLock int iCancelStateSave
-#define mutex_cancelsafe_lock(mut) \
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &iCancelStateSave); \
- d_pthread_mutex_lock(mut); \
- pthread_cleanup_push(mutexCancelCleanup, mut); \
- pthread_setcancelstate(iCancelStateSave, NULL);
-#define mutex_cancelsafe_unlock(mut) pthread_cleanup_pop(1)
-
/* some useful constants */
#define DEFVARS_mutexProtection\
int bLockedOpIsLocked=0