diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2008-01-29 09:13:59 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2008-01-29 09:13:59 +0000 |
commit | 33a8ec9855b7e7674ab2b1a6e4814b08652296de (patch) | |
tree | bb15bd7523a4b95075b7d2d5b92b42b844d5e562 | |
parent | 8b73362a4a88aaa3642db398d17e65eab871d9ed (diff) | |
download | rsyslog-33a8ec9855b7e7674ab2b1a6e4814b08652296de.tar.gz rsyslog-33a8ec9855b7e7674ab2b1a6e4814b08652296de.tar.xz rsyslog-33a8ec9855b7e7674ab2b1a6e4814b08652296de.zip |
- moved correct retry logic into action processing queue
- removed debugging support from sync class, debug class now provides much
more
-rw-r--r-- | action.c | 41 | ||||
-rw-r--r-- | sync.c | 22 | ||||
-rw-r--r-- | sync.h | 5 | ||||
-rw-r--r-- | syslogd.c | 2 |
4 files changed, 16 insertions, 54 deletions
@@ -127,8 +127,6 @@ actionConstructFinalize(action_t *pThis) /* create queue */ RUNLOG_VAR("%d", ActionQueType); CHKiRet(queueConstruct(&pThis->pQueue, ActionQueType, 1, 10, (rsRetVal (*)(void*,void*))actionCallDoAction)); -RUNLOG_VAR("%p", pThis->pQueue); -RUNLOG_VAR("%x", pThis->pQueue->iObjCooCKiE ); /* ... set some properties ... */ @@ -270,20 +268,6 @@ rsRetVal actionDbgPrint(action_t *pThis) } -/* schedule the message for processing - * rgerhards, 2008-01-28 - */ -rsRetVal -actionDoAction(action_t *pAction) -{ - DEFiRet; -RUNLOG_VAR("%p", pAction->f_pMsg); - ISOBJ_TYPE_assert(pAction->f_pMsg, Msg); - iRet = queueEnqObj(pAction->pQueue, (void*) MsgAddRef(pAction->f_pMsg)); - RETiRet; -} - - /* call the DoAction output plugin entry point * rgerhards, 2008-01-28 */ @@ -306,8 +290,17 @@ actionCallDoAction(action_t *pAction, msg_t *pMsg) do { RUNLOG_STR("going into do_action call loop"); RUNLOG_VAR("%d", iRetries); - /* call configured action */ - iRet = pAction->pMod->mod.om.doAction(pAction->ppMsgs, pAction->f_pMsg->msgFlags, pAction->pModData); + /* first check if we are suspended and, if so, retry */ + if(actionIsSuspended(pAction)) { +dbgprintf("action %p is suspended\n", pAction); + iRet = actionTryResume(pAction); + } + + if(iRet == RS_RET_OK) { + /* call configured action */ + iRet = pAction->pMod->mod.om.doAction(pAction->ppMsgs, pAction->f_pMsg->msgFlags, pAction->pModData); + } + RUNLOG_VAR("%d", iRet); if(iRet == RS_RET_SUSPENDED) { /* ok, this calls for our retry logic... */ @@ -342,6 +335,7 @@ finalize_it: pAction->ppMsgs[i] = NULL; } } + MsgDestruct(&pMsg); /* we are now finished with the message */ RETiRet; } @@ -437,9 +431,9 @@ actionWriteToAction(action_t *pAction) time(&pAction->f_time); /* we need this for message repeation processing */ /* When we reach this point, we have a valid, non-disabled action. - * So let's execute it. -- rgerhards, 2007-07-24 + * So let's enqueue our message for execution. -- rgerhards, 2007-07-24 */ - iRet = actionDoAction(pAction); + iRet = queueEnqObj(pAction->pQueue, (void*) MsgAddRef(pAction->f_pMsg)); finalize_it: if(pMsgSave != NULL) { @@ -460,9 +454,6 @@ finalize_it: } - - - /* call the configured action. Does all necessary housekeeping. * rgerhards, 2007-08-01 */ @@ -498,10 +489,6 @@ actionCallAction(action_t *pAction, msg_t *pMsg) ABORT_FINALIZE(RS_RET_OK); } - if(actionIsSuspended(pAction)) { - CHKiRet(actionTryResume(pAction)); - } - /* don't output marks to recently written files */ if ((pMsg->msgFlags & MARK) && (time(NULL) - pAction->f_time) < MarkInterval / 2) { ABORT_FINALIZE(RS_RET_OK); @@ -53,25 +53,3 @@ SyncObjExit(pthread_mutex_t **mut) *mut = NULL; } } - -#ifndef NDEBUG -/* lock an object. The synchronization tool (mutex) must be passed in. - */ -void -lockObj(pthread_mutex_t *mut) -{ - BEGINfunc - d_pthread_mutex_lock(mut); - ENDfunc -} - -/* unlock an object. The synchronization tool (mutex) must be passed in. - */ -void -unlockObj(pthread_mutex_t *mut) -{ - BEGINfunc - d_pthread_mutex_unlock(mut); - ENDfunc -} -#endif /* #ifndef NDEBUG */ @@ -38,13 +38,8 @@ * operations. If we run in debug mode, we use functions, because they * are better to trace in the stackframe. */ -#ifdef NDEBUG #define LockObj(x) d_pthread_mutex_lock((x)->Sync_mut) #define UnlockObj(x) d_pthread_mutex_unlock((x)->Sync_mut) -#else -#define LockObj(x) lockObj((x)->Sync_mut) -#define UnlockObj(x) unlockObj((x)->Sync_mut) -#endif void SyncObjInit(pthread_mutex_t **mut); void SyncObjExit(pthread_mutex_t **mut); @@ -2259,6 +2259,7 @@ DEFFUNC_llExecFunc(flushRptdMsgsActions) assert(pAction != NULL); + BEGINfunc LockObj(pAction); if (pAction->f_prevcount && time(NULL) >= REPEATTIME(pAction)) { dbgprintf("flush %s: repeated %d times, %d sec.\n", @@ -2269,6 +2270,7 @@ DEFFUNC_llExecFunc(flushRptdMsgsActions) } UnlockObj(pAction); + ENDfunc return RS_RET_OK; /* we ignore errors, we can not do anything either way */ } |