diff options
| author | Donatas Abraitis <donatas@opensourcerouting.org> | 2023-11-04 13:58:55 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-04 13:58:55 +0200 |
| commit | 4bdba57861d1325b42b5b81c118bf76b51f172e5 (patch) | |
| tree | 97e9ebbdb2ea7e809915b173a15bbeb7a2625e6b /lib/workqueue.c | |
| parent | d4c596d77f34ac613a8c2be54a819f08df01feeb (diff) | |
| parent | 2a65f05d77f88f96d4385040d01492e805e1cc44 (diff) | |
Merge pull request #14724 from donaldsharp/workqueue_cleanup
Workqueue cleanup
Diffstat (limited to 'lib/workqueue.c')
| -rw-r--r-- | lib/workqueue.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/lib/workqueue.c b/lib/workqueue.c index 2281c4c369..d630af1d1d 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,8 +281,7 @@ 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: { @@ -276,9 +291,6 @@ void work_queue_run(struct event *thread) item->ran--; goto stats; } - case WQ_RETRY_LATER: { - goto stats; - } case WQ_REQUEUE: { item->ran--; work_queue_item_requeue(wq, item); @@ -296,11 +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 - */ - fallthrough; case WQ_SUCCESS: default: { work_queue_item_remove(wq, item); @@ -352,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); |
