Merged silc_1_0_branch to trunk.
[silc.git] / lib / silcutil / silcschedule.c
index 5ea2ebf00a743da144358d6fd9c506face1902c2..169f4535d275646112b0ab364dfb0b32e4da2aa0 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 1998 - 2003 Pekka Riikonen
+  Copyright (C) 1998 - 2005 Pekka Riikonen
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -607,6 +607,16 @@ bool silc_schedule_one(SilcSchedule schedule, int timeout_usecs)
     return FALSE;
   }
 
+  /* If the task queues aren't initialized or we aren't valid anymore
+     we will return */
+  if ((!schedule->fd_queue && !schedule->timeout_queue
+       && !schedule->generic_queue) || schedule->valid == FALSE) {
+    SILC_LOG_DEBUG(("Scheduler not valid anymore, exiting"));
+    if (!schedule->is_locked)
+      SILC_SCHEDULE_UNLOCK(schedule);
+    return FALSE;
+  }
+
   /* Calculate next timeout for silc_select(). This is the timeout value
      when at earliest some of the timeout tasks expire. */
   silc_mutex_lock(schedule->timeout_queue->lock);