Smaller changes. Changed order when set_wakeup is called after some task is removed...
authort3sserakt <t3ss@posteo.de>
Tue, 8 Aug 2017 16:30:33 +0000 (18:30 +0200)
committert3sserakt <t3ss@posteo.de>
Tue, 8 Aug 2017 16:30:33 +0000 (18:30 +0200)
src/util/scheduler.c

index 42309c1997bea3218337337e907853c2228e341d..e90763fb449ee5add409652a8571c897c636d3e7 100644 (file)
@@ -536,13 +536,15 @@ check_ready (const struct GNUNET_NETWORK_FDSet *rs,
       pos->reason |= GNUNET_SCHEDULER_REASON_TIMEOUT;
     if (0 == pos->reason)
       break;
-    scheduler_driver->set_wakeup (scheduler_driver->cls,
-                                  pending_timeout_head->timeout);
+
     GNUNET_CONTAINER_DLL_remove (pending_timeout_head,
                                  pending_timeout_tail,
                                  pos);
     if (pending_timeout_last == pos)
       pending_timeout_last = NULL;
+    else
+      scheduler_driver->set_wakeup (scheduler_driver->cls,
+                                    pending_timeout_head->timeout);
     queue_ready_task (pos);
   }
   pos = pending_head;
@@ -1080,6 +1082,7 @@ GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Task *task)
           scheduler_driver->set_wakeup (scheduler_driver->cls,
                                         pending_timeout_head->timeout);
       }
+      //TODO check if this is redundant
       if (task == pending_timeout_last)
         pending_timeout_last = NULL;
     }
@@ -1920,9 +1923,12 @@ GNUNET_SCHEDULER_run_from_driver (struct GNUNET_SCHEDULER_Handle *sh)
     GNUNET_CONTAINER_DLL_remove (pending_timeout_head,
                                  pending_timeout_tail,
                                  pos);
-    scheduler_driver->set_wakeup(scheduler_driver->cls,pending_timeout_head->timeout);
+
     if (pending_timeout_last == pos)
       pending_timeout_last = NULL;
+    else
+      scheduler_driver->set_wakeup(scheduler_driver->cls,pending_timeout_head->timeout);
+
     queue_ready_task (pos);
   }