summaryrefslogtreecommitdiffstats
path: root/wtp.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-01-27 16:24:05 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2008-01-27 16:24:05 +0000
commit4b44a34d71b8b9bfc2574adeff4e735a8e97c876 (patch)
tree3807fd8ccb94b4a3d9beb9da754bfa0bb3d46c5c /wtp.c
parent7d8b1c293746d325db7f93d343a952e382da9ddd (diff)
downloadrsyslog-4b44a34d71b8b9bfc2574adeff4e735a8e97c876.tar.gz
rsyslog-4b44a34d71b8b9bfc2574adeff4e735a8e97c876.tar.xz
rsyslog-4b44a34d71b8b9bfc2574adeff4e735a8e97c876.zip
some more fixing and cleanup on the queue shutdown sequence
Diffstat (limited to 'wtp.c')
-rw-r--r--wtp.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/wtp.c b/wtp.c
index 3e5fb937..817204d8 100644
--- a/wtp.c
+++ b/wtp.c
@@ -286,7 +286,6 @@ wtpShutdownAll(wtp_t *pThis, wtpState_t tShutdownCmd, struct timespec *ptTimeout
RUNLOG_VAR("%d", pThis->iCurNumWrkThrd);
/* and wait for their termination */
-dbgprintf("%s: waiting for mutex %p\n", wtpGetDbgHdr(pThis), &pThis->mut);
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &iCancelStateSave);
d_pthread_mutex_lock(&pThis->mut);
pthread_cleanup_push(mutexCancelCleanup, &pThis->mut);
@@ -582,6 +581,30 @@ DEFpropSetMethFP(wtp, pfOnWorkerStartup, rsRetVal(*pVal)(void*));
DEFpropSetMethFP(wtp, pfOnWorkerShutdown, rsRetVal(*pVal)(void*));
+/* return the current number of worker threads.
+ * TODO: atomic operation would bring a nice performance
+ * enhancemcent
+ * rgerhards, 2008-01-27
+ */
+int
+wtpGetCurNumWrkr(wtp_t *pThis, int bLockMutex)
+{
+ DEFVARS_mutexProtection;
+ int iNumWrkr;
+
+ BEGINfunc
+ ISOBJ_TYPE_assert(pThis, wtp);
+
+ BEGIN_MTX_PROTECTED_OPERATIONS(&pThis->mut, bLockMutex);
+ iNumWrkr = pThis->iCurNumWrkThrd;
+ END_MTX_PROTECTED_OPERATIONS(&pThis->mut);
+
+RUNLOG_VAR("%d", iNumWrkr);
+ ENDfunc
+ return iNumWrkr;
+}
+
+
/* set the debug header message
* The passed-in string is duplicated. So if the caller does not need
* it any longer, it must free it. Must be called only before object is finalized.