summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/ChangeLog10
-rw-r--r--lib/workqueue.c19
-rw-r--r--lib/workqueue.h6
3 files changed, 22 insertions, 13 deletions
diff --git a/lib/ChangeLog b/lib/ChangeLog
index 11506202..537a705d 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,13 @@
+2005-04-27 Paul Jakma <paul.jakma@sun.com>
+
+ * workqueue.h: (struct work_queue_item) change retry_count to ran,
+ its a count of number item has been run.
+ * workqueue.c: (show_work_queues) Fix formating of slightly
+ bugfix: fix SIGFPE if wq->runs is 0.
+ (work_queue_run) retry logic was slightly wrong.
+ cycles.best is 0 initialy, granularity is 1, so update best
+ if cycles >= granularity, not just >.
+
2005-04-26 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* buffer.c (buffer_write): Comment out call to buffer_flush_available.
diff --git a/lib/workqueue.c b/lib/workqueue.c
index 0c9592d2..7931d19c 100644
--- a/lib/workqueue.c
+++ b/lib/workqueue.c
@@ -163,7 +163,7 @@ DEFUN(show_work_queues,
vty_out (vty,
"%8s %11s %8s %21s%s",
- "List","(ms) ","Q. Runs","Cycle Counts ",
+ "List","(ms) ","Q. Runs","Cycle Counts ",
VTY_NEWLINE);
vty_out (vty,
"%8s %5s %5s %8s %7s %6s %6s %s%s",
@@ -176,12 +176,13 @@ DEFUN(show_work_queues,
for (ALL_LIST_ELEMENTS_RO ((&work_queues), node, wq))
{
- vty_out (vty,"%8d %5d %5d %8ld %7d %6d %6u %s%s",
+ vty_out (vty,"%8d %5d %5d %8ld %7d %6d %6u %s%s",
listcount (wq->items),
wq->spec.delay, wq->spec.hold,
wq->runs,
- wq->cycles.best, wq->cycles.granularity,
- (unsigned int)(wq->cycles.total / wq->runs),
+ wq->cycles.best, wq->cycles.granularity,
+ (wq->runs) ?
+ (unsigned int) (wq->cycles.total / wq->runs) : 0,
wq->name,
VTY_NEWLINE);
}
@@ -232,7 +233,7 @@ work_queue_run (struct thread *thread)
assert (item && item->data);
/* dont run items which are past their allowed retries */
- if (item->retry_count >= wq->spec.max_retries)
+ if (item->ran > wq->spec.max_retries)
{
/* run error handler, if any */
if (wq->spec.errorfunc)
@@ -245,21 +246,19 @@ work_queue_run (struct thread *thread)
do
{
ret = wq->spec.workfunc (item->data);
- item->retry_count++;
+ item->ran++;
}
while ((ret == WQ_RETRY_NOW)
- && (item->retry_count < wq->spec.max_retries));
+ && (item->ran < wq->spec.max_retries));
switch (ret)
{
case WQ_RETRY_LATER:
{
- item->retry_count++;
goto stats;
}
case WQ_REQUEUE:
{
- item->retry_count++;
work_queue_item_requeue (wq, node);
break;
}
@@ -301,7 +300,7 @@ stats:
: WORK_QUEUE_MIN_GRANULARITY);
}
- if (cycles > (wq->cycles.granularity))
+ if (cycles >= (wq->cycles.granularity))
{
if (cycles > wq->cycles.best)
wq->cycles.best = cycles;
diff --git a/lib/workqueue.h b/lib/workqueue.h
index 45fffe7b..5b4e82e5 100644
--- a/lib/workqueue.h
+++ b/lib/workqueue.h
@@ -42,7 +42,7 @@ typedef enum
struct work_queue_item
{
void *data; /* opaque data */
- unsigned short retry_count; /* number of times retried */
+ unsigned short ran; /* # of times item has been run */
};
struct work_queue
@@ -54,13 +54,13 @@ struct work_queue
/* specification for this work queue */
struct {
/* work function to process items with */
- wq_item_status (*workfunc) (void *);
+ wq_item_status (*workfunc) ();
/* error handling function, optional */
void (*errorfunc) (struct work_queue *, struct work_queue_item *);
/* callback to delete user specific item data */
- void (*del_item_data) (void *);
+ void (*del_item_data) ();
/* max number of retries to make for item that errors */
unsigned int max_retries;