Skip to content

Commit

Permalink
librdmacm/cmtime: Force use of multiple threads in work queue
Browse files Browse the repository at this point in the history
When multiple work items are added to the work queue, it's
possible that only a single thread is signaled to process
the work.  The result is that the other threads continue
to wait on the condition.  Since the test inserts work using
a loop, this occurs frequently, and the behavior appears as
a singled thread app, even if multiple threads were
requested.

After removing a work item, if other work items remain,
signal the condition to wake up another thread.

Signed-off-by: Sean Hefty <[email protected]>
  • Loading branch information
Sean Hefty committed Apr 23, 2024
1 parent 79ab39a commit 39fdafa
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions librdmacm/examples/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,8 @@ static void *wq_handler(void *arg)
}

item = wq_remove(wq);
if (wq->head)
pthread_cond_signal(&wq->cond);
pthread_mutex_unlock(&wq->lock);

item->work_handler(item);
Expand Down

0 comments on commit 39fdafa

Please sign in to comment.