set shutdown flag also for ready tasks
authorChristian Grothoff <christian@grothoff.org>
Fri, 13 Nov 2009 20:58:20 +0000 (20:58 +0000)
committerChristian Grothoff <christian@grothoff.org>
Fri, 13 Nov 2009 20:58:20 +0000 (20:58 +0000)
src/util/scheduler.c

index 1df907a203b8920770bdbe01017ebf1a28f1b26d..3f3b1437760fb7294a51fcef2d8dbd28fdf64bee 100644 (file)
@@ -398,6 +398,7 @@ void
 GNUNET_SCHEDULER_shutdown (struct GNUNET_SCHEDULER_Handle *sched)
 {
   struct Task *pos;
+  int i;
 
   pos = sched->pending;
   while (pos != NULL)
@@ -408,6 +409,18 @@ GNUNET_SCHEDULER_shutdown (struct GNUNET_SCHEDULER_Handle *sched)
          readyness-factors */
       pos = pos->next;
     }
+  for (i=0;i<GNUNET_SCHEDULER_PRIORITY_COUNT;i++)
+    {
+      pos = sched->ready[i];
+      while (pos != NULL)
+       {
+         pos->reason |= GNUNET_SCHEDULER_REASON_SHUTDOWN;
+         /* we don't move the task into the ready queue yet; check_ready
+            will do that later, possibly adding additional
+            readyness-factors */
+         pos = pos->next;
+       }
+    }  
 }