summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-01-29 09:13:59 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2008-01-29 09:13:59 +0000
commit33a8ec9855b7e7674ab2b1a6e4814b08652296de (patch)
treebb15bd7523a4b95075b7d2d5b92b42b844d5e562
parent8b73362a4a88aaa3642db398d17e65eab871d9ed (diff)
downloadrsyslog-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.c41
-rw-r--r--sync.c22
-rw-r--r--sync.h5
-rw-r--r--syslogd.c2
4 files changed, 16 insertions, 54 deletions
diff --git a/action.c b/action.c
index a3cd9370..872c2085 100644
--- a/action.c
+++ b/action.c
@@ -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);
diff --git a/sync.c b/sync.c
index 913469a0..c6003afc 100644
--- a/sync.c
+++ b/sync.c
@@ -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 */
diff --git a/sync.h b/sync.h
index 204737dc..33e2658d 100644
--- a/sync.h
+++ b/sync.h
@@ -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);
diff --git a/syslogd.c b/syslogd.c
index f5d9adb7..a1e89530 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -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 */
}