summaryrefslogtreecommitdiffstats
path: root/lib/workqueue.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 04:24:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 04:24:31 +0000
commitacb594b1d825c6e12369cebb941968ec08c840ce (patch)
treed544788908e7353a4f117e2991f15f4236a0c963 /lib/workqueue.c
parentAdding upstream version 9.1. (diff)
downloadfrr-acb594b1d825c6e12369cebb941968ec08c840ce.tar.xz
frr-acb594b1d825c6e12369cebb941968ec08c840ce.zip
Adding upstream version 10.0.upstream/10.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lib/workqueue.c')
-rw-r--r--lib/workqueue.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/lib/workqueue.c b/lib/workqueue.c
index fa5d585..d630af1 100644
--- a/lib/workqueue.c
+++ b/lib/workqueue.c
@@ -42,6 +42,15 @@ static void work_queue_item_free(struct work_queue_item *item)
return;
}
+static inline void work_queue_item_dequeue(struct work_queue *wq,
+ struct work_queue_item *item)
+{
+ assert(wq->item_count > 0);
+
+ wq->item_count--;
+ STAILQ_REMOVE(&wq->items, item, work_queue_item, wq);
+}
+
static void work_queue_item_remove(struct work_queue *wq,
struct work_queue_item *item)
{
@@ -133,6 +142,13 @@ static int work_queue_schedule(struct work_queue *wq, unsigned int delay)
return 0;
}
+static inline void work_queue_item_enqueue(struct work_queue *wq,
+ struct work_queue_item *item)
+{
+ STAILQ_INSERT_TAIL(&wq->items, item, wq);
+ wq->item_count++;
+}
+
void work_queue_add(struct work_queue *wq, void *data)
{
struct work_queue_item *item;
@@ -265,17 +281,14 @@ void work_queue_run(struct event *thread)
do {
ret = wq->spec.workfunc(wq, item->data);
item->ran++;
- } while ((ret == WQ_RETRY_NOW)
- && (item->ran < wq->spec.max_retries));
+ } while (item->ran < wq->spec.max_retries);
switch (ret) {
case WQ_QUEUE_BLOCKED: {
/* decrement item->ran again, cause this isn't an item
- * specific error, and fall through to WQ_RETRY_LATER
+ * specific error, and retry later
*/
item->ran--;
- }
- case WQ_RETRY_LATER: {
goto stats;
}
case WQ_REQUEUE: {
@@ -295,10 +308,6 @@ void work_queue_run(struct event *thread)
titem = item;
break;
}
- case WQ_RETRY_NOW:
- /* a RETRY_NOW that gets here has exceeded max_tries, same as
- * ERROR */
- /* fallthru */
case WQ_SUCCESS:
default: {
work_queue_item_remove(wq, item);
@@ -350,8 +359,7 @@ stats:
/* Is the queue done yet? If it is, call the completion callback. */
if (!work_queue_empty(wq)) {
- if (ret == WQ_RETRY_LATER ||
- ret == WQ_QUEUE_BLOCKED)
+ if (ret == WQ_QUEUE_BLOCKED)
work_queue_schedule(wq, wq->spec.retry);
else
work_queue_schedule(wq, 0);