[pisa-src] r1104 - trunk/libpisa

  • From: Thomas Jansen <mithi@xxxxxxxxx>
  • To: pisa-src@xxxxxxxxxxxxx
  • Date: Tue, 13 Oct 2009 13:24:05 +0200

Author: tjansen
Date: Tue Oct 13 13:24:05 2009
New Revision: 1104

Log:
Fixed segfault when task list is empty.

Modified:
   trunk/libpisa/scheduler.c

Modified: trunk/libpisa/scheduler.c
==============================================================================
--- trunk/libpisa/scheduler.c   Tue Oct 13 13:16:56 2009        (r1103)
+++ trunk/libpisa/scheduler.c   Tue Oct 13 13:24:05 2009        (r1104)
@@ -65,7 +65,7 @@
 
                pthread_mutex_lock(&mutex_list);
                gettimeofday(&now, NULL);
-               if (pisa_time_before(&head->due, &now)) {
+               if (head && pisa_time_before(&head->due, &now)) {
                        /* (at least) the first action is due now, raise the
                         * flag. As we have to reschedule afterwards, sleep
                         * for a _long_ time. We don't care about tv_usec. */
@@ -75,7 +75,10 @@
                        /* No action is due now, sleep until the head is due
                         * (or we are woken up for rescheduling). */
                        *flag = 0;
-                       timersub(&head->due, &now, &timeout);
+                       if (head)
+                               timersub(&head->due, &now, &timeout);
+                       else
+                               timeout.tv_sec = 1000000;
                }
                pthread_mutex_unlock(&mutex_list);
        }

Other related posts:

  • » [pisa-src] r1104 - trunk/libpisa - Thomas Jansen