Skip to content

Commit f93a6a0

Browse files
committed
cleaner compensation for spurious increment of pending in poke
1 parent 62f900e commit f93a6a0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/queue.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,13 @@ _dispatch_root_queue_init_pthread_pool(dispatch_root_queue_context_t qc,
694694
thread_pool_size = pool_size;
695695
}
696696
qc->dgq_thread_pool_size = thread_pool_size;
697+
if (qc->dgq_kworkqueue == (void*)(~0ul)) {
698+
// when _dispatch_root_queues_init is invoked from
699+
// _dispatch_global_queue_poke_slow we need to clear
700+
// dgq_pending here because qc->dgq_kworkqueue wasn't
701+
// initialized to (~0ul) when we went through _dispatch_global_queue_poke
702+
qc->dgq_pending = 0;
703+
}
697704
#if HAVE_PTHREAD_WORKQUEUES
698705
if (qc->dgq_qos) {
699706
(void)dispatch_assume_zero(pthread_attr_init(&pqc->dpq_thread_attr));
@@ -4060,9 +4067,6 @@ _dispatch_global_queue_poke(dispatch_queue_t dq, int n, int floor)
40604067
#if HAVE_PTHREAD_WORKQUEUES
40614068
dispatch_root_queue_context_t qc = dq->do_ctxt;
40624069
if (
4063-
#if HAVE_INTERNAL_PTHREAD_WORKQUEUE
4064-
false && /* counting done in poke_slow for this config */
4065-
#endif
40664070
#if DISPATCH_USE_PTHREAD_POOL
40674071
(qc->dgq_kworkqueue != (void*)(~0ul)) &&
40684072
#endif

0 commit comments

Comments
 (0)