X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=urcu%2Fworkqueue-fifo.h;h=a2bbd909fdb1ae3923c8743d155752dceb016802;hb=0a14cd14bb8de4385c133f5cec3c4ec06f41ee8b;hp=883f41f3feec4c0869f27c794f44a420ba80fdb5;hpb=a649215929e3af5a0dd26d9fc5bb9ed49e677773;p=urcu.git diff --git a/urcu/workqueue-fifo.h b/urcu/workqueue-fifo.h index 883f41f..a2bbd90 100644 --- a/urcu/workqueue-fifo.h +++ b/urcu/workqueue-fifo.h @@ -86,6 +86,7 @@ void urcu_workqueue_init(struct urcu_workqueue *queue) __cds_wfcq_init(&queue->head, &queue->tail); urcu_wait_queue_init(&queue->waitqueue); CDS_INIT_LIST_HEAD(&queue->sibling_head); + pthread_mutex_init(&queue->sibling_lock, NULL); queue->shutdown = false; } @@ -138,6 +139,7 @@ void urcu_worker_init(struct urcu_worker *worker, int flags) worker->flags = flags; urcu_wait_node_init(&worker->wait_node, URCU_WAIT_RUNNING); worker->own = NULL; + worker->wait_node.node.next = NULL; } static inline @@ -204,7 +206,7 @@ bool ___urcu_grab_work(struct urcu_worker *worker, bool steal) { enum cds_wfcq_ret splice_ret; - struct cds_wfcq_head tmp_head; + struct __cds_wfcq_head tmp_head; struct cds_wfcq_tail tmp_tail; struct cds_wfcq_node *node; @@ -213,7 +215,7 @@ bool ___urcu_grab_work(struct urcu_worker *worker, */ if (cds_wfcq_empty(src_head, src_tail)) return false; - cds_wfcq_init(&tmp_head, &tmp_tail); + __cds_wfcq_init(&tmp_head, &tmp_tail); /* Ensure that we preserve FIFO work order. */ assert(!steal || worker->own == NULL); @@ -254,7 +256,7 @@ got_node: } /* Splice into worker workqueue. */ - splice_ret = cds_wfcq_splice_blocking(&worker->head, + splice_ret = __cds_wfcq_splice_blocking(&worker->head, &worker->tail, &tmp_head, &tmp_tail); @@ -364,7 +366,8 @@ enum urcu_accept_ret urcu_accept_work(struct urcu_workqueue *queue, has_work = ___urcu_grab_work(worker, &queue->head, &queue->tail, 0); /* Don't wait if we have work to do. */ - if (has_work || !cds_wfcq_empty(&worker->head, &worker->tail)) + if (has_work || worker->own + || !cds_wfcq_empty(&worker->head, &worker->tail)) goto do_work; /* Try to steal work from sibling instead of blocking */ if (__urcu_steal_work(queue, worker))