From b4d4366986b464ae4a75594ab7df0a5edb2ee08f Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 11 Aug 2011 15:05:00 +0200 Subject: bugfixes for tag emulation - bugfix: potential hang condition during tag emulation - bugfix: too-early string termination during tag emulation --- ChangeLog | 4 +++- runtime/msg.c | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 71ac7448..92d582fd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ --------------------------------------------------------------------------- -Version 5.8.5 [V5-stable] (al), 2011-??-?? +Version 5.8.5 [V5-stable] (rgerhards/al), 2011-??-?? +- bugfix: potential hang condition during tag emulation +- bugfix: too-early string termination during tag emulation - bugfix: The NUL-Byte for the syslogtag was not copied in MsgDup (msg.c) --------------------------------------------------------------------------- Version 5.8.4 [V5-stable] (al), 2011-08-10 diff --git a/runtime/msg.c b/runtime/msg.c index 9fdaded3..b18fb530 100644 --- a/runtime/msg.c +++ b/runtime/msg.c @@ -1697,8 +1697,11 @@ static inline void tryEmulateTAG(msg_t *pM, sbool bLockMutex) if(bLockMutex == LOCK_MUTEX) MsgLock(pM); - if(pM->iLenTAG > 0) + if(pM->iLenTAG > 0) { + if(bLockMutex == LOCK_MUTEX) + MsgUnlock(pM); return; /* done, no need to emulate */ + } if(getProtocolVersion(pM) == 1) { if(!strcmp(getPROCID(pM, MUTEX_ALREADY_LOCKED), "-")) { @@ -1708,7 +1711,7 @@ static inline void tryEmulateTAG(msg_t *pM, sbool bLockMutex) /* now we can try to emulate */ lenTAG = snprintf((char*)bufTAG, CONF_TAG_MAXSIZE, "%s[%s]", getAPPNAME(pM, MUTEX_ALREADY_LOCKED), getPROCID(pM, MUTEX_ALREADY_LOCKED)); - bufTAG[32] = '\0'; /* just to make sure... */ + bufTAG[sizeof(bufTAG)-1] = '\0'; /* just to make sure... */ MsgSetTAG(pM, bufTAG, lenTAG); } } -- cgit v1.2.3 From e54e8724767e938c028823a42e3f54820067cfcd Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Fri, 12 Aug 2011 10:18:51 +0200 Subject: minor doc: made body tag parsable for web site scripts --- doc/rsyslog_pgsql.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/rsyslog_pgsql.html b/doc/rsyslog_pgsql.html index dcb9dc3a..21516ec8 100644 --- a/doc/rsyslog_pgsql.html +++ b/doc/rsyslog_pgsql.html @@ -30,7 +30,7 @@ --> - +

Writing syslog messages to MySQL, PostgreSQL or any other supported Database

Written by Rainer @@ -333,4 +333,4 @@ Gerhards, Marc Schiffbauer and Adiscon<



- \ No newline at end of file + -- cgit v1.2.3 From 169791752520693d3c81568037bfa319e5081819 Mon Sep 17 00:00:00 2001 From: Andre Lorbach Date: Fri, 12 Aug 2011 14:48:43 +0200 Subject: Added debug output into message parsers needed for bugtracking Changed version to 5.8.5-pre1 --- configure.ac | 2 +- runtime/msg.c | 5 +++++ tools/pmrfc3164.c | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 2706ec06..7ed85851 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.61) -AC_INIT([rsyslog],[5.8.4],[rsyslog@lists.adiscon.com]) +AC_INIT([rsyslog],[5.8.5-pre1],[rsyslog@lists.adiscon.com]) AM_INIT_AUTOMAKE m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) diff --git a/runtime/msg.c b/runtime/msg.c index b18fb530..f1de8130 100644 --- a/runtime/msg.c +++ b/runtime/msg.c @@ -1661,6 +1661,8 @@ void MsgSetTAG(msg_t *pMsg, uchar* pszBuf, size_t lenBuf) uchar *pBuf; assert(pMsg != NULL); +dbgprintf("MsgSetTAG in: len %d, pszBuf: %s\n", lenBuf, pszBuf); + freeTAG(pMsg); pMsg->iLenTAG = lenBuf; @@ -1679,6 +1681,8 @@ void MsgSetTAG(msg_t *pMsg, uchar* pszBuf, size_t lenBuf) memcpy(pBuf, pszBuf, pMsg->iLenTAG); pBuf[pMsg->iLenTAG] = '\0'; /* this also works with truncation! */ + +dbgprintf("MsgSetTAG exit: pMsg->iLenTAG %d, pMsg->TAG.szBuf: %s\n", pMsg->iLenTAG, pMsg->TAG.szBuf); } @@ -1737,6 +1741,7 @@ getTAG(msg_t *pM, uchar **ppBuf, int *piLen) *piLen = pM->iLenTAG; } } +dbgprintf("getTAG: len %d, buf '%s'\n", *piLen, *ppBuf); } diff --git a/tools/pmrfc3164.c b/tools/pmrfc3164.c index 635ca985..d56e53f0 100644 --- a/tools/pmrfc3164.c +++ b/tools/pmrfc3164.c @@ -176,6 +176,7 @@ CODESTARTparse * in RFC3164...). We now receive the full size, but will modify the * outputs so that only 32 characters max are used by default. */ +dbgprintf("pmrfc3164:tag:in: lenMsg %d, p2parse: '%s'\n", lenMsg, p2parse); i = 0; while(lenMsg > 0 && *p2parse != ':' && *p2parse != ' ' && i < CONF_TAG_MAXSIZE) { bufParseTAG[i++] = *p2parse++; @@ -191,6 +192,7 @@ CODESTARTparse * is considered OK. So we do not need to check for empty TAG. -- rgerhards, 2009-06-23 */ bufParseTAG[i] = '\0'; /* terminate string */ +dbgprintf("pmrfc3164:tag:done: lenMsg %d, i %d, bufParseTAG: '%s'\n", lenMsg, i, bufParseTAG); MsgSetTAG(pMsg, bufParseTAG, i); } else {/* we enter this code area when the user has instructed rsyslog NOT * to parse HOSTNAME and TAG - rgerhards, 2006-03-13 -- cgit v1.2.3 From 47ed9921b6c9fe49d4aadf244f7df1ce4d05a5b3 Mon Sep 17 00:00:00 2001 From: Andre Lorbach Date: Thu, 18 Aug 2011 09:36:59 +0200 Subject: bugfix: fixed incorrect state handling for Discard Action (transactions) --- ChangeLog | 3 +++ action.c | 34 ++++++++++++++++++++++++++++++++-- configure.ac | 2 +- runtime/queue.c | 13 +++++++++++++ 4 files changed, 49 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 92d582fd..df5cd048 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,9 @@ Version 5.8.5 [V5-stable] (rgerhards/al), 2011-??-?? - bugfix: potential hang condition during tag emulation - bugfix: too-early string termination during tag emulation - bugfix: The NUL-Byte for the syslogtag was not copied in MsgDup (msg.c) +- bugfix: fixed incorrect state handling for Discard Action (transactions) + Note: This caused all messages in a batch to be set to COMMITTED, + even if they were discarded. --------------------------------------------------------------------------- Version 5.8.4 [V5-stable] (al), 2011-08-10 - bugfix: potential misadressing in property replacer diff --git a/action.c b/action.c index 54a05fc3..869185e9 100644 --- a/action.c +++ b/action.c @@ -962,6 +962,7 @@ tryDoAction(action_t *pAction, batch_t *pBatch, int *pnElem) iCommittedUpTo = i; dbgprintf("XXXXX: tryDoAction %p, pnElem %d, nElem %d\n", pAction, *pnElem, pBatch->nElem); while(iElemProcessed <= *pnElem && i < pBatch->nElem) { +dbgprintf("XXXXX: pre nElem %d, state %d\n", pBatch->nElem, pBatch->pElem[i].state); if(*(pBatch->pbShutdownImmediate)) ABORT_FINALIZE(RS_RET_FORCE_TERM); /* NOTE: do NOT extend the filter below! Anything else must be done on the @@ -979,14 +980,20 @@ dbgprintf("XXXXX: tryDoAction %p, pnElem %d, nElem %d\n", pAction, *pnElem, if(localRet == RS_RET_OK) { /* mark messages as committed */ while(iCommittedUpTo <= i) { +dbgprintf("XXXXX: setting nElem %d to 3/COMM\n", iCommittedUpTo); pBatch->pElem[iCommittedUpTo].bPrevWasSuspended = 0; /* we had success! */ - pBatch->pElem[iCommittedUpTo++].state = BATCH_STATE_COMM; + batchSetElemState(pBatch, iCommittedUpTo, BATCH_STATE_COMM); + ++iCommittedUpTo; + //pBatch->pElem[iCommittedUpTo++].state = BATCH_STATE_COMM; } } else if(localRet == RS_RET_PREVIOUS_COMMITTED) { /* mark messages as committed */ while(iCommittedUpTo < i) { +dbgprintf("XXXXX: setting2 nElem %d to 3/COMM\n", iCommittedUpTo); pBatch->pElem[iCommittedUpTo].bPrevWasSuspended = 0; /* we had success! */ - pBatch->pElem[iCommittedUpTo++].state = BATCH_STATE_COMM; + batchSetElemState(pBatch, iCommittedUpTo, BATCH_STATE_COMM); + ++iCommittedUpTo; + //pBatch->pElem[iCommittedUpTo++].state = BATCH_STATE_COMM; } pBatch->pElem[i].state = BATCH_STATE_SUB; } else if(localRet == RS_RET_DEFER_COMMIT) { @@ -1000,6 +1007,7 @@ dbgprintf("XXXXX: tryDoAction %p, pnElem %d, nElem %d\n", pAction, *pnElem, FINALIZE; } } +dbgprintf("XXXXX: post nElem %d, state %d\n", pBatch->nElem, pBatch->pElem[i].state); ++i; ++iElemProcessed; } @@ -1011,6 +1019,15 @@ finalize_it: RETiRet; } +/* debug aid */ +static void displayBatchState(batch_t *pBatch) +{ + int i; + for(i = 0 ; i < pBatch->nElem ; ++i) { + dbgprintf("XXXXX: displayBatchState2 %p[%d]: %d\n", pBatch, i, pBatch->pElem[i].state); + } +} + /* submit a batch for actual action processing. * The first nElem elements are processed. This function calls itself @@ -1030,6 +1047,8 @@ submitBatch(action_t *pAction, batch_t *pBatch, int nElem) assert(pBatch != NULL); +dbgprintf("XXXX: submitBatch pre:\n"); +displayBatchState(pBatch); wasDoneTo = pBatch->iDoneUpTo; bDone = 0; do { @@ -1043,16 +1062,23 @@ submitBatch(action_t *pAction, batch_t *pBatch, int nElem) /* try commit transaction, once done, we can simply do so as if * that return state was returned from tryDoAction(). */ +dbgprintf("XXXX: calling finishBatch\n"); +displayBatchState(pBatch); localRet = finishBatch(pAction, pBatch); } +dbgprintf("XXXX: 10\n"); if( localRet == RS_RET_OK || localRet == RS_RET_PREVIOUS_COMMITTED || localRet == RS_RET_DEFER_COMMIT) { +dbgprintf("XXXX: bdone = 1\n"); +displayBatchState(pBatch); bDone = 1; } else if(localRet == RS_RET_SUSPENDED) { +dbgprintf("XXXX: 20\n"); ; /* do nothing, this will retry the full batch */ } else if(localRet == RS_RET_ACTION_FAILED) { +dbgprintf("XXXX: 25\n"); /* in this case, everything not yet committed is BAD */ for(i = pBatch->iDoneUpTo ; i < wasDoneTo + nElem ; ++i) { if( pBatch->pElem[i].state != BATCH_STATE_DISC @@ -1063,6 +1089,7 @@ submitBatch(action_t *pAction, batch_t *pBatch, int nElem) } bDone = 1; } else { +dbgprintf("XXXX: 30\n"); if(nElem == 1) { batchSetElemState(pBatch, pBatch->iDoneUpTo, BATCH_STATE_BAD); bDone = 1; @@ -1081,6 +1108,8 @@ submitBatch(action_t *pAction, batch_t *pBatch, int nElem) ABORT_FINALIZE(RS_RET_FORCE_TERM); finalize_it: +dbgprintf("XXXX: submitBatch post:\n"); +displayBatchState(pBatch); RETiRet; } @@ -1552,6 +1581,7 @@ doQueueEnqObjDirectBatch(action_t *pAction, batch_t *pBatch) * this is not necessary, because in that case we enqueue only what actually needs * to be processed. */ +dbgprintf("XXXXX: in doQeuueEnqDiretbatch, %d\n", pAction->bExecWhenPrevSusp); if(pAction->bExecWhenPrevSusp) { bNeedSubmit = 0; bModifiedFilter = 0; diff --git a/configure.ac b/configure.ac index 7ed85851..c57426fd 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.61) -AC_INIT([rsyslog],[5.8.5-pre1],[rsyslog@lists.adiscon.com]) +AC_INIT([rsyslog],[5.8.5-pre2],[rsyslog@lists.adiscon.com]) AM_INIT_AUTOMAKE m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) diff --git a/runtime/queue.c b/runtime/queue.c index 00eb76c7..554c6a43 100644 --- a/runtime/queue.c +++ b/runtime/queue.c @@ -88,6 +88,15 @@ static rsRetVal qqueueMultiEnqObjDirect(qqueue_t *pThis, multi_submit_t *pMultiS #define QUEUE_CHECKPOINT 1 #define QUEUE_NO_CHECKPOINT 0 +/* debug aid */ +static void displayBatchState(batch_t *pBatch) +{ + int i; + for(i = 0 ; i < pBatch->nElem ; ++i) { + dbgprintf("XXXXX: displayBatchState %p[%d]: %d\n", pBatch, i, pBatch->pElem[i].state); + } +} + /*********************************************************************** * we need a private data structure, the "to-delete" list. As C does * not provide any partly private data structures, we implement this @@ -882,6 +891,8 @@ rsRetVal qqueueEnqObjDirectBatch(qqueue_t *pThis, batch_t *pBatch) ASSERT(pThis != NULL); +dbgprintf("XXXXX: pre call consumer\n"); +displayBatchState(pBatch); /* calling the consumer is quite different here than it is from a worker thread */ /* we need to provide the consumer's return value back to the caller because in direct * mode the consumer probably has a lot to convey (which get's lost in the other modes @@ -892,6 +903,8 @@ rsRetVal qqueueEnqObjDirectBatch(qqueue_t *pThis, batch_t *pBatch) */ iRet = pThis->pConsumer(pThis->pUsr, pBatch, &pThis->bShutdownImmediate); +dbgprintf("XXXXX: post call consumer\n"); +displayBatchState(pBatch); RETiRet; } -- cgit v1.2.3 From 154747929f87010b444af2d552f980daafe451e6 Mon Sep 17 00:00:00 2001 From: Andre Lorbach Date: Thu, 18 Aug 2011 13:15:10 +0200 Subject: removed debug code from action.c and runtime/queue.c after testing --- action.c | 17 ----------------- runtime/queue.c | 4 ---- 2 files changed, 21 deletions(-) diff --git a/action.c b/action.c index 869185e9..50699c01 100644 --- a/action.c +++ b/action.c @@ -962,7 +962,6 @@ tryDoAction(action_t *pAction, batch_t *pBatch, int *pnElem) iCommittedUpTo = i; dbgprintf("XXXXX: tryDoAction %p, pnElem %d, nElem %d\n", pAction, *pnElem, pBatch->nElem); while(iElemProcessed <= *pnElem && i < pBatch->nElem) { -dbgprintf("XXXXX: pre nElem %d, state %d\n", pBatch->nElem, pBatch->pElem[i].state); if(*(pBatch->pbShutdownImmediate)) ABORT_FINALIZE(RS_RET_FORCE_TERM); /* NOTE: do NOT extend the filter below! Anything else must be done on the @@ -980,7 +979,6 @@ dbgprintf("XXXXX: pre nElem %d, state %d\n", pBatch->nElem, pBatch->pElem[i] if(localRet == RS_RET_OK) { /* mark messages as committed */ while(iCommittedUpTo <= i) { -dbgprintf("XXXXX: setting nElem %d to 3/COMM\n", iCommittedUpTo); pBatch->pElem[iCommittedUpTo].bPrevWasSuspended = 0; /* we had success! */ batchSetElemState(pBatch, iCommittedUpTo, BATCH_STATE_COMM); ++iCommittedUpTo; @@ -989,7 +987,6 @@ dbgprintf("XXXXX: setting nElem %d to 3/COMM\n", iCommittedUpTo); } else if(localRet == RS_RET_PREVIOUS_COMMITTED) { /* mark messages as committed */ while(iCommittedUpTo < i) { -dbgprintf("XXXXX: setting2 nElem %d to 3/COMM\n", iCommittedUpTo); pBatch->pElem[iCommittedUpTo].bPrevWasSuspended = 0; /* we had success! */ batchSetElemState(pBatch, iCommittedUpTo, BATCH_STATE_COMM); ++iCommittedUpTo; @@ -1007,7 +1004,6 @@ dbgprintf("XXXXX: setting2 nElem %d to 3/COMM\n", iCommittedUpTo); FINALIZE; } } -dbgprintf("XXXXX: post nElem %d, state %d\n", pBatch->nElem, pBatch->pElem[i].state); ++i; ++iElemProcessed; } @@ -1047,8 +1043,6 @@ submitBatch(action_t *pAction, batch_t *pBatch, int nElem) assert(pBatch != NULL); -dbgprintf("XXXX: submitBatch pre:\n"); -displayBatchState(pBatch); wasDoneTo = pBatch->iDoneUpTo; bDone = 0; do { @@ -1062,23 +1056,16 @@ displayBatchState(pBatch); /* try commit transaction, once done, we can simply do so as if * that return state was returned from tryDoAction(). */ -dbgprintf("XXXX: calling finishBatch\n"); -displayBatchState(pBatch); localRet = finishBatch(pAction, pBatch); } -dbgprintf("XXXX: 10\n"); if( localRet == RS_RET_OK || localRet == RS_RET_PREVIOUS_COMMITTED || localRet == RS_RET_DEFER_COMMIT) { -dbgprintf("XXXX: bdone = 1\n"); -displayBatchState(pBatch); bDone = 1; } else if(localRet == RS_RET_SUSPENDED) { -dbgprintf("XXXX: 20\n"); ; /* do nothing, this will retry the full batch */ } else if(localRet == RS_RET_ACTION_FAILED) { -dbgprintf("XXXX: 25\n"); /* in this case, everything not yet committed is BAD */ for(i = pBatch->iDoneUpTo ; i < wasDoneTo + nElem ; ++i) { if( pBatch->pElem[i].state != BATCH_STATE_DISC @@ -1089,7 +1076,6 @@ dbgprintf("XXXX: 25\n"); } bDone = 1; } else { -dbgprintf("XXXX: 30\n"); if(nElem == 1) { batchSetElemState(pBatch, pBatch->iDoneUpTo, BATCH_STATE_BAD); bDone = 1; @@ -1108,8 +1094,6 @@ dbgprintf("XXXX: 30\n"); ABORT_FINALIZE(RS_RET_FORCE_TERM); finalize_it: -dbgprintf("XXXX: submitBatch post:\n"); -displayBatchState(pBatch); RETiRet; } @@ -1581,7 +1565,6 @@ doQueueEnqObjDirectBatch(action_t *pAction, batch_t *pBatch) * this is not necessary, because in that case we enqueue only what actually needs * to be processed. */ -dbgprintf("XXXXX: in doQeuueEnqDiretbatch, %d\n", pAction->bExecWhenPrevSusp); if(pAction->bExecWhenPrevSusp) { bNeedSubmit = 0; bModifiedFilter = 0; diff --git a/runtime/queue.c b/runtime/queue.c index 554c6a43..9012abeb 100644 --- a/runtime/queue.c +++ b/runtime/queue.c @@ -891,8 +891,6 @@ rsRetVal qqueueEnqObjDirectBatch(qqueue_t *pThis, batch_t *pBatch) ASSERT(pThis != NULL); -dbgprintf("XXXXX: pre call consumer\n"); -displayBatchState(pBatch); /* calling the consumer is quite different here than it is from a worker thread */ /* we need to provide the consumer's return value back to the caller because in direct * mode the consumer probably has a lot to convey (which get's lost in the other modes @@ -903,8 +901,6 @@ displayBatchState(pBatch); */ iRet = pThis->pConsumer(pThis->pUsr, pBatch, &pThis->bShutdownImmediate); -dbgprintf("XXXXX: post call consumer\n"); -displayBatchState(pBatch); RETiRet; } -- cgit v1.2.3