diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2009-07-08 16:58:53 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2009-07-08 16:58:53 +0200 |
commit | 9f286c0c4c21128c66305166ae379d3f7b07f673 (patch) | |
tree | 4c54a382a3489c088518fa504c0d5fede4783589 /runtime | |
parent | e13e417f4c47b8fc8d3163f38ede254a42e00a6e (diff) | |
download | rsyslog-9f286c0c4c21128c66305166ae379d3f7b07f673.tar.gz rsyslog-9f286c0c4c21128c66305166ae379d3f7b07f673.tar.xz rsyslog-9f286c0c4c21128c66305166ae379d3f7b07f673.zip |
optimizing queue thread handling
... first commit in a series of more. Makes worker threads detached. Needs more
testing (will be done soon) and if it works as expected, we can further reduce
code.
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/wti.c | 4 | ||||
-rw-r--r-- | runtime/wtp.c | 8 |
2 files changed, 8 insertions, 4 deletions
diff --git a/runtime/wti.c b/runtime/wti.c index 917b456b..93c66028 100644 --- a/runtime/wti.c +++ b/runtime/wti.c @@ -263,7 +263,7 @@ wtiJoinThrd(wti_t *pThis) if (pThis->thrdID == 0) { dbgprintf("worker %s was already stopped\n", wtiGetDbgHdr(pThis)); } else { - pthread_join(pThis->thrdID, NULL); + //pthread_join(pThis->thrdID, NULL); wtiSetState(pThis, eWRKTHRD_STOPPED, 0, MUTEX_ALREADY_LOCKED); /* back to virgin... */ pThis->thrdID = 0; /* invalidate the thread ID so that we do not accidently find reused ones */ dbgprintf("worker %s has stopped\n", wtiGetDbgHdr(pThis)); @@ -399,7 +399,7 @@ wtiWorker(wti_t *pThis) /* now we have our identity, on to real processing */ while(1) { /* loop will be broken below - need to do mutex locks */ /* process any pending thread requests */ - wtpProcessThrdChanges(pWtp); + // wtpProcessThrdChanges(pWtp); if(pWtp->pfRateLimiter != NULL) { /* call rate-limiter, if defined */ pWtp->pfRateLimiter(pWtp->pUsr); diff --git a/runtime/wtp.c b/runtime/wtp.c index 81e4446d..59553984 100644 --- a/runtime/wtp.c +++ b/runtime/wtp.c @@ -493,11 +493,12 @@ wtpWorker(void *arg) /* the arg is actually a wti object, even though we are in static rsRetVal wtpStartWrkr(wtp_t *pThis, int bLockMutex) { - DEFiRet; DEFVARS_mutexProtection; wti_t *pWti; int i; int iState; + pthread_attr_t attr; + DEFiRet; ISOBJ_TYPE_assert(pThis, wtp); @@ -521,7 +522,10 @@ wtpStartWrkr(wtp_t *pThis, int bLockMutex) pWti = pThis->pWrkr[i]; wtiSetState(pWti, eWRKTHRD_RUN_CREATED, 0, LOCK_MUTEX); - iState = pthread_create(&(pWti->thrdID), NULL, wtpWorker, (void*) pWti); + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + iState = pthread_create(&(pWti->thrdID), &attr, wtpWorker, (void*) pWti); + pthread_attr_destroy(&attr); /* TODO: we could globally reuse such an attribute 2009-07-08 */ dbgprintf("%s: started with state %d, num workers now %d\n", wtpGetDbgHdr(pThis), iState, pThis->iCurNumWrkThrd); |