summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2012-03-15 13:34:05 +0100
committerMichael Biebl <biebl@debian.org>2012-03-15 13:34:05 +0100
commitc1860fd74db97b8311e5d8f018ded8145fb0b0f5 (patch)
tree7119c56e0aedd8aeda0e4f84a761d79ede01a724 /runtime
parent4b6db682f04b13a031bc48d240266b2fbd670ae7 (diff)
downloadrsyslog-c1860fd74db97b8311e5d8f018ded8145fb0b0f5.tar.gz
Imported Upstream version 5.8.9upstream/5.8.9
Diffstat (limited to 'runtime')
-rw-r--r--runtime/queue.c10
-rw-r--r--runtime/queue.h2
-rw-r--r--runtime/statsobj.c36
-rw-r--r--runtime/statsobj.h55
-rw-r--r--runtime/wti.c2
-rw-r--r--runtime/wtp.c2
6 files changed, 69 insertions, 38 deletions
diff --git a/runtime/queue.c b/runtime/queue.c
index 9012abe..621a4ee 100644
--- a/runtime/queue.c
+++ b/runtime/queue.c
@@ -1787,7 +1787,8 @@ qqueueChkStopWrkrDA(qqueue_t *pThis)
{
DEFiRet;
-//DBGPRINTF("XXXX: chkStopWrkrDA called, low watermark %d, phys Size %d\n", pThis->iLowWtrMrk, getPhysicalQueueSize(pThis));
+ /*DBGPRINTF("XXXX: chkStopWrkrDA called, low watermark %d, log Size %d, phys Size %d, bEnqOnly %d\n",
+ pThis->iLowWtrMrk, getLogicalQueueSize(pThis), getPhysicalQueueSize(pThis), pThis->bEnqOnly);*/
if(pThis->bEnqOnly) {
iRet = RS_RET_TERMINATE_WHEN_IDLE;
}
@@ -1808,6 +1809,8 @@ static rsRetVal
ChkStopWrkrReg(qqueue_t *pThis)
{
DEFiRet;
+ /*DBGPRINTF("XXXX: chkStopWrkrReg called, low watermark %d, log Size %d, phys Size %d, bEnqOnly %d\n",
+ pThis->iLowWtrMrk, getLogicalQueueSize(pThis), getPhysicalQueueSize(pThis), pThis->bEnqOnly);*/
if(pThis->bEnqOnly) {
iRet = RS_RET_TERMINATE_NOW;
} else if(pThis->pqParent != NULL) {
@@ -1844,6 +1847,7 @@ qqueueStart(qqueue_t *pThis) /* this is the ConstructionFinalizer */
int wrk;
uchar *qName;
size_t lenBuf;
+ int iQueueSizeSave;
ASSERT(pThis != NULL);
@@ -1925,6 +1929,8 @@ qqueueStart(qqueue_t *pThis) /* this is the ConstructionFinalizer */
qName = obj.GetName((obj_t*)pThis);
CHKiRet(statsobj.Construct(&pThis->statsobj));
CHKiRet(statsobj.SetName(pThis->statsobj, qName));
+ /* we need to save the queue size, as the stats module initializes it to 0! */
+ /* iQueueSize is a dual-use counter: no init, no mutex! */
CHKiRet(statsobj.AddCounter(pThis->statsobj, UCHAR_CONSTANT("size"),
ctrType_Int, &pThis->iQueueSize));
@@ -1936,7 +1942,7 @@ qqueueStart(qqueue_t *pThis) /* this is the ConstructionFinalizer */
CHKiRet(statsobj.AddCounter(pThis->statsobj, UCHAR_CONSTANT("full"),
ctrType_IntCtr, &pThis->ctrFull));
- pThis->ctrMaxqsize = 0;
+ pThis->ctrMaxqsize = 0; /* no mutex needed, thus no init call */
CHKiRet(statsobj.AddCounter(pThis->statsobj, UCHAR_CONSTANT("maxqsize"),
ctrType_Int, &pThis->ctrMaxqsize));
diff --git a/runtime/queue.h b/runtime/queue.h
index 9705718..7ef5673 100644
--- a/runtime/queue.h
+++ b/runtime/queue.h
@@ -169,7 +169,7 @@ struct queue_s {
statsobj_t *statsobj;
STATSCOUNTER_DEF(ctrEnqueued, mutCtrEnqueued);
STATSCOUNTER_DEF(ctrFull, mutCtrFull);
- int ctrMaxqsize;
+ int ctrMaxqsize; /* NOT guarded by a mutex */
};
diff --git a/runtime/statsobj.c b/runtime/statsobj.c
index 131605e..367ddb1 100644
--- a/runtime/statsobj.c
+++ b/runtime/statsobj.c
@@ -3,25 +3,23 @@
* This object provides a statistics-gathering facility inside rsyslog. This
* functionality will be pragmatically implemented and extended.
*
- * Copyright 2010 Rainer Gerhards and Adiscon GmbH.
+ * Copyright 2010-2012 Adiscon GmbH.
*
* This file is part of the rsyslog runtime library.
*
- * The rsyslog runtime library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * The rsyslog runtime library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with the rsyslog runtime library. If not, see <http://www.gnu.org/licenses/>.
- *
- * A copy of the GPL can be found in the file "COPYING" in this distribution.
- * A copy of the LGPL can be found in the file "COPYING.LESSER" in this distribution.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * -or-
+ * see COPYING.ASL20 in the source distribution
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
#include "config.h"
@@ -139,6 +137,10 @@ finalize_it:
/* add a counter to an object
* ctrName is duplicated, caller must free it if requried
+ * NOTE: The counter is READ-ONLY and MUST NOT be modified (most
+ * importantly, it must not be initialized, so the caller must
+ * ensure the counter is properly initialized before AddCounter()
+ * is called.
*/
static rsRetVal
addCounter(statsobj_t *pThis, uchar *ctrName, statsCtrType_t ctrType, void *pCtr)
@@ -154,11 +156,9 @@ addCounter(statsobj_t *pThis, uchar *ctrName, statsCtrType_t ctrType, void *pCtr
switch(ctrType) {
case ctrType_IntCtr:
ctr->val.pIntCtr = (intctr_t*) pCtr;
- *(ctr->val.pIntCtr) = 0;
break;
case ctrType_Int:
ctr->val.pInt = (int*) pCtr;
- *(ctr->val.pInt) = 0;
break;
}
addCtrToList(pThis, ctr);
diff --git a/runtime/statsobj.h b/runtime/statsobj.h
index 44c26be..9027988 100644
--- a/runtime/statsobj.h
+++ b/runtime/statsobj.h
@@ -1,24 +1,22 @@
/* The statsobj object.
*
- * Copyright 2010 Rainer Gerhards and Adiscon GmbH.
+ * Copyright 2010-2012 Rainer Gerhards and Adiscon GmbH.
*
* This file is part of the rsyslog runtime library.
*
- * The rsyslog runtime library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * The rsyslog runtime library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with the rsyslog runtime library. If not, see <http://www.gnu.org/licenses/>.
- *
- * A copy of the GPL can be found in the file "COPYING" in this distribution.
- * A copy of the LGPL can be found in the file "COPYING.LESSER" in this distribution.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * -or-
+ * see COPYING.ASL20 in the source distribution
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
#ifndef INCLUDED_STATSOBJ_H
#define INCLUDED_STATSOBJ_H
@@ -96,6 +94,31 @@ PROTOTYPEObj(statsobj);
* Unfortunately, this does not work if counter is e.g. "pThis->ctr".
* So we decided, for clarity, to always insist on specifying the mutex
* name (after all, it's just a few more keystrokes...).
+ * --------------------------------------------------------------------
+ * NOTE WELL
+ * --------------------------------------------------------------------
+ * There are actually two types of stats counters: "regular" counters,
+ * which are only used for stats purposes and "dual" counters, which
+ * are primarily used for other purposes but can be included in stats
+ * as well. ALL regular counters MUST be initialized with
+ * STATSCOUNTER_INIT and only be modified by STATSCOUNTER_* functions.
+ * They MUST NOT be used for any other purpose (if this seems to make
+ * sense, consider changing it to a dual counter).
+ * Dual counters are somewhat dangerous in that a single variable is
+ * used for two purposes: the actual application need and stats
+ * counting. However, this is supported for performance reasons, as it
+ * provides insight into the inner engine workings without need for
+ * additional counters (and their maintenance code). Dual counters
+ * MUST NOT be modified by STATSCOUNTER_* functions. Most importantly,
+ * it is expected that the actua application code provides proper
+ * (enough) synchronized access to these counters. Most importantly,
+ * this means they have NO stats-system mutex associated to them.
+ *
+ * The interface function AddCounter() is a read-only function. It
+ * only provides the stats subsystem with a reference to a counter.
+ * It is irrelevant if the counter is a regular or dual one. For that
+ * reason, AddCounter() must not modify the counter contents, as in
+ * the case of a dual counter application code may be broken.
*/
#define STATSCOUNTER_DEF(ctr, mut) \
intctr_t ctr; \
diff --git a/runtime/wti.c b/runtime/wti.c
index 0b85c36..69da2e9 100644
--- a/runtime/wti.c
+++ b/runtime/wti.c
@@ -315,6 +315,8 @@ wtiWorker(wti_t *pThis)
if(localRet == RS_RET_IDLE) {
if(terminateRet == RS_RET_TERMINATE_WHEN_IDLE || bInactivityTOOccured) {
d_pthread_mutex_unlock(pWtp->pmutUsr);
+ dbgoprint((obj_t*) pThis, "terminating worker terminateRet=%d, bInactivityTOOccured=%d\n",
+ terminateRet, bInactivityTOOccured);
break; /* end of loop */
}
doIdleProcessing(pThis, pWtp, &bInactivityTOOccured);
diff --git a/runtime/wtp.c b/runtime/wtp.c
index e615fb1..a53a988 100644
--- a/runtime/wtp.c
+++ b/runtime/wtp.c
@@ -309,7 +309,7 @@ wtpWrkrExecCleanup(wti_t *pWti)
wtiSetState(pWti, WRKTHRD_STOPPED);
ATOMIC_DEC(&pThis->iCurNumWrkThrd, &pThis->mutCurNumWrkThrd);
- DBGPRINTF("%s: Worker thread %lx, terminated, um workers now %d\n",
+ DBGPRINTF("%s: Worker thread %lx, terminated, num workers now %d\n",
wtpGetDbgHdr(pThis), (unsigned long) pWti,
ATOMIC_FETCH_32BIT(&pThis->iCurNumWrkThrd, &pThis->mutCurNumWrkThrd));