From 834206c8a9cb9a729e972b468524de5eb3d2ef02 Mon Sep 17 00:00:00 2001 From: caochao Date: Thu, 17 Feb 2022 09:26:34 +0800 Subject: [PATCH] fixed 4256975 from https://gitee.com/caochao123/distributedschedule_samgr_lite/pulls/50 modify lock race condition Signed-off-by: caochao Change-Id: Id88cab569dc0850f9e3cd1c300b213bc0325d384 --- samgr/adapter/posix/queue_adapter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100755 => 100644 samgr/adapter/posix/queue_adapter.c diff --git a/samgr/adapter/posix/queue_adapter.c b/samgr/adapter/posix/queue_adapter.c old mode 100755 new mode 100644 index 7be92c6..da7f031 --- a/samgr/adapter/posix/queue_adapter.c +++ b/samgr/adapter/posix/queue_adapter.c @@ -65,11 +65,11 @@ int QUEUE_Pop(MQueueId queueId, void *element, uint8 *pri, int timeout) } LockFreeBlockQueue *queue = (LockFreeBlockQueue *)queueId; + pthread_mutex_lock(&queue->rMutex); if (LFQUE_Pop(queue->queue, element, pri) == EC_SUCCESS) { return EC_SUCCESS; } - pthread_mutex_lock(&queue->rMutex); while (LFQUE_Pop(queue->queue, element, pri) != EC_SUCCESS) { pthread_cond_wait(&queue->cond, &queue->rMutex); } -- Gitee