Commit Graph

3 Commits

Author SHA1 Message Date
Vadim Yanitskiy 9c972934f9 core: fix wrong logic in _osmo_it_q_dequeue()
If the given queue is empty, queue->list.next points to &queue->list.
Current implementation would call llist_del() on the queue's llist_head,
decrement queue->current_length (which will be 0), and return a pointer
to &queue->list to the caller.  This is completely wrong.

- Use the existing item_dequeue(), which does exactly what we need.
- Do not decrement the current_length if nothing was dequeued.
- Uncomment code in the unit test, we should not crash anymore.

Change-Id: I63094df73b166b549616c869ad908e9f4f7d46d1
Fixes: CID#336557
2023-12-09 15:23:11 +07:00
Vadim Yanitskiy 09c8bfce07 tests/it_q: add tc_enqueue/dequeue testcase
This patch is adding a simple testcase, which does the following:

* enqueue up to the limit (12 items),
* dequeue up to the limit (12 items).

Everything works as expected, unless you attempt to dequeue from
an empty queue: the test binary segfaults.  The problem is explained
and fixed in a subsequent patch.

Change-Id: Ie0edbf00e656fbe231952bdbccfd37d143e8b2b1
Related: CID#336557
2023-12-09 15:23:09 +07:00
Harald Welte e4cd267ab1 Add inter-thread queue
This adds an inter-thread queue "it_q" to libosmocore. With it_q,
one can perform thread-safe enqueing of messages to another thread,
who will receive the related messages triggered via an eventfd
handled in the usual libosmocore select loop abstraction.

Change-Id: Ie7d0c5fec715a2a577fae014b0b8a0e9c38418ef
2021-01-06 00:22:13 +01:00