From 1b4a1902031babbb3907cd0e73d86c1fa0da0a3d Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Mon, 14 Jan 2008 13:55:32 +0000 Subject: optimized code --- queue.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/queue.c b/queue.c index b9e6471f..8010a45d 100644 --- a/queue.c +++ b/queue.c @@ -1060,9 +1060,10 @@ queueEnqObj(queue_t *pThis, void *pUsr) * thread is canceled (most important use case is input module termination). * rgerhards, 2008-01-08 */ - pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &iCancelStateSave); - if(pThis->pWrkThrds != NULL) + if(pThis->pWrkThrds != NULL) { + pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &iCancelStateSave); pthread_mutex_lock(pThis->mut); + } while(pThis->iQueueSize >= pThis->iMaxQueueSize) { dbgprintf("Queue 0x%lx: enqueueMsg: queue FULL - waiting to drain.\n", (unsigned long) pThis); @@ -1083,9 +1084,9 @@ finalize_it: pthread_mutex_unlock(pThis->mut); i = pthread_cond_signal(pThis->notEmpty); dbgprintf("Queue 0x%lx: EnqueueMsg signaled condition (%d)\n", (unsigned long) pThis, i); + pthread_setcancelstate(iCancelStateSave, NULL); } - pthread_setcancelstate(iCancelStateSave, NULL); return iRet; } -- cgit