Skip to content

Commit

Permalink
lib: Remove unused WQ_RETRY_XXX enums
Browse files Browse the repository at this point in the history
These enum's have been around since 2005 and FRR
still does not have any users of these particular
values.  After almost 20 years, let's simplify the
code slightly and remove them.

Signed-off-by: Donald Sharp <[email protected]>
  • Loading branch information
donaldsharp committed Nov 3, 2023
1 parent b14f755 commit 2a65f05
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 21 deletions.
14 changes: 2 additions & 12 deletions lib/workqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,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: {
Expand All @@ -292,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);
Expand All @@ -312,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);
Expand Down Expand Up @@ -368,8 +359,7 @@ void work_queue_run(struct event *thread)

/* 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);
Expand Down
5 changes: 2 additions & 3 deletions lib/workqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ DECLARE_MTYPE(WORK_QUEUE);
/* action value, for use by item processor and item error handlers */
typedef enum {
WQ_SUCCESS = 0,
WQ_RETRY_NOW, /* retry immediately */
WQ_RETRY_LATER, /* retry later, cease processing work queue */
WQ_REQUEUE, /* requeue item, continue processing work queue */
WQ_REQUEUE, /* requeue item, continue processing work queue */
WQ_QUEUE_BLOCKED, /* Queue cant be processed at this time.
* Similar to WQ_RETRY_LATER, but doesn't penalise
* the particular item.. */
Expand Down Expand Up @@ -144,6 +142,7 @@ bool work_queue_is_scheduled(struct work_queue *wq);
/* Helpers, exported for thread.c and command.c */
extern void work_queue_run(struct event *thread);

/* Function to initialize the workqueue cli */
extern void workqueue_cmd_init(void);

#ifdef __cplusplus
Expand Down
6 changes: 0 additions & 6 deletions tests/lib/test_heavy_wq.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,6 @@ static wq_item_status slow_func(struct work_queue *wq, void *data)
for (j = 0; j < 300; j++)
x += sin(x) * j;

if ((hn->i % ITERS_LATER) == 0)
return WQ_RETRY_LATER;

if ((hn->i % ITERS_ERR) == 0)
return WQ_RETRY_NOW;

if ((hn->i % ITERS_PRINT) == 0)
printf("%s did %d, x = %g\n", hn->str, hn->i, x);

Expand Down

0 comments on commit 2a65f05

Please sign in to comment.