]> git.puffer.fish Git - matthieu/frr.git/commitdiff
2005-04-27 Paul Jakma <paul.jakma@sun.com>
authorpaul <paul>
Wed, 27 Apr 2005 12:39:27 +0000 (12:39 +0000)
committerpaul <paul>
Wed, 27 Apr 2005 12:39:27 +0000 (12:39 +0000)
* 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 >.

lib/ChangeLog
lib/workqueue.c
lib/workqueue.h

index 115062026f4734e42f9c5b647121490dd23c6cae..537a705d0c9ce5438a37ee2770b1bde23a550702 100644 (file)
@@ -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.
index 0c9592d2a43f6c0031a04e30a9b10dd2e1e58964..7931d19ce3d2006b4f4702170eb7fef6df769773 100644 (file)
@@ -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;
index 45fffe7ba7088c1976e26145db53d68ce5604503..5b4e82e5ccac800a61aba392a79406c82c765f87 100644 (file)
@@ -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;