summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2009-06-23 15:17:55 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2009-06-23 15:17:55 +0200
commitb1f2e53921b7ab19c363a63de47a0e7a35866052 (patch)
tree6b87e6a2a868482e16b64a6244e37512ebe4d4ab
parentb50d13a6a97c0b6fa14807775ae0edf52ef015fb (diff)
downloadrsyslog-b1f2e53921b7ab19c363a63de47a0e7a35866052.tar.gz
rsyslog-b1f2e53921b7ab19c363a63de47a0e7a35866052.tar.xz
rsyslog-b1f2e53921b7ab19c363a63de47a0e7a35866052.zip
prevented unneccessary apc calls
-rw-r--r--runtime/apc.c7
-rw-r--r--runtime/stream.c15
-rw-r--r--runtime/stream.h5
-rw-r--r--tools/syslogd.c3
4 files changed, 19 insertions, 11 deletions
diff --git a/runtime/apc.c b/runtime/apc.c
index b0b5f298..5919191d 100644
--- a/runtime/apc.c
+++ b/runtime/apc.c
@@ -257,8 +257,11 @@ execScheduled(void)
END_MTX_PROTECTED_OPERATIONS_UNCOND(&listMutex);
CHKiRet(iRet);
- DBGPRINTF("running apc scheduler - we have %s to execute\n",
- pExecList == NULL ? "nothing" : "something");
+ if(pExecList != NULL) {
+ DBGPRINTF("running apc scheduler - we have %s to execute\n",
+ pExecList == NULL ? "nothing" : "something");
+ }
+
for(pCurr = pExecList ; pCurr != NULL ; pCurr = pNext) {
dbgprintf("executing apc list entry %p, apc %p\n", pCurr, pCurr->pApc);
pNext = pCurr->pNext;
diff --git a/runtime/stream.c b/runtime/stream.c
index f9859617..00c726d9 100644
--- a/runtime/stream.c
+++ b/runtime/stream.c
@@ -74,6 +74,7 @@ flushApc(void *param1, void __attribute__((unused)) *param2)
BEGIN_MTX_PROTECTED_OPERATIONS_UNCOND(&pThis->mut);
strmFlush(pThis);
+ pThis->apcRequested = 0;
END_MTX_PROTECTED_OPERATIONS_UNCOND(&pThis->mut);
}
@@ -1001,12 +1002,16 @@ scheduleFlushRequest(strm_t *pThis)
apc_t *pApc;
DEFiRet;
- CHKiRet(apc.CancelApc(pThis->apcID));
+ if(!pThis->apcRequested) {
+ /* we do an request only if none is yet pending */
+ pThis->apcRequested = 1;
+ // TODO: find similar thing later CHKiRet(apc.CancelApc(pThis->apcID));
dbgprintf("XXX: requesting to add apc!\n");
- CHKiRet(apc.Construct(&pApc));
- CHKiRet(apc.SetProcedure(pApc, (void (*)(void*, void*))flushApc));
- CHKiRet(apc.SetParam1(pApc, pThis));
- CHKiRet(apc.ConstructFinalize(pApc, &pThis->apcID));
+ CHKiRet(apc.Construct(&pApc));
+ CHKiRet(apc.SetProcedure(pApc, (void (*)(void*, void*))flushApc));
+ CHKiRet(apc.SetParam1(pApc, pThis));
+ CHKiRet(apc.ConstructFinalize(pApc, &pThis->apcID));
+ }
finalize_it:
RETiRet;
diff --git a/runtime/stream.h b/runtime/stream.h
index e3ad32b1..ac003c7b 100644
--- a/runtime/stream.h
+++ b/runtime/stream.h
@@ -104,8 +104,8 @@ typedef struct strm_s {
int64 iCurrOffs;/* current offset */
int64 *pUsrWCntr; /* NULL or a user-provided counter that receives the nbr of bytes written since the last CntrSet() */
/* dynamic properties, valid only during file open, not to be persistet */
- int bDisabled; /* should file no longer be written to? (currently set only if omfile file size limit fails) */
- int bSync; /* sync this file after every write? */
+ bool bDisabled; /* should file no longer be written to? (currently set only if omfile file size limit fails) */
+ bool bSync; /* sync this file after every write? */
size_t sIOBufSize;/* size of IO buffer */
uchar *pszDir; /* Directory */
int lenDir;
@@ -123,6 +123,7 @@ typedef struct strm_s {
int iFlushInterval; /* flush in which interval - 0, no flushing */
apc_id_t apcID; /* id of current Apc request (used for cancelling) */
pthread_mutex_t mut;/* mutex for flush in async mode */
+ int apcRequested; /* is an apc Requested? */
/* support for omfile size-limiting commands, special counters, NOT persisted! */
off_t iSizeLimit; /* file size limit, 0 = no limit */
uchar *pszSizeLimitCmd; /* command to carry out when size limit is reached */
diff --git a/tools/syslogd.c b/tools/syslogd.c
index 178ad455..385fef1c 100644
--- a/tools/syslogd.c
+++ b/tools/syslogd.c
@@ -1469,7 +1469,6 @@ DEFFUNC_llExecFunc(flushRptdMsgsActions)
assert(pAction != NULL);
BEGINfunc
-RUNLOG_VAR("%p", pAction);
LockObj(pAction);
/* TODO: time() performance: the call below could be moved to
* the beginn of the llExec(). This makes it slightly less correct, but
@@ -2586,7 +2585,7 @@ mainloop(void)
* but a once-a-day wakeup should be quite acceptable. -- rgerhards, 2008-06-09
*/
//tvSelectTimeout.tv_sec = (bReduceRepeatMsgs == 1) ? TIMERINTVL : 86400 /*1 day*/;
-tvSelectTimeout.tv_sec = 5; // TESTING ONLY!!! TODO: change back!!!
+ tvSelectTimeout.tv_sec = TIMERINTVL; /* TODO: change this back to the above code when we have a better solution for apc */
tvSelectTimeout.tv_usec = 0;
select(1, NULL, NULL, NULL, &tvSelectTimeout);
if(bFinished)