updates.
[silc.git] / lib / silcutil / silcschedule.c
index 8a8e581cc5a22c4c28808c775838b1bd20cc69f4..4084371e9a76dd11573a7c851aa661ab33d5e23c 100644 (file)
@@ -250,6 +250,20 @@ bool silc_schedule_uninit(SilcSchedule schedule)
   return TRUE;
 }
 
+/* Enlarge the capabilities of the scheduler to handle tasks to `max_tasks'. */
+
+bool silc_schedule_reinit(SilcSchedule schedule, int max_tasks)
+{
+  silc_mutex_lock(schedule->lock);
+  if (schedule->max_fd <= max_tasks)
+    return FALSE;
+  schedule->fd_list = silc_realloc(schedule->fd_list, 
+                                  (sizeof(*schedule->fd_list) * max_tasks));
+  schedule->max_fd = max_tasks;
+  silc_mutex_unlock(schedule->lock);
+  return TRUE;
+}
+
 /* Stops the schedule even if it is not supposed to be stopped yet. 
    After calling this, one should call silc_schedule_uninit (after the 
    silc_schedule has returned). */
@@ -257,9 +271,7 @@ bool silc_schedule_uninit(SilcSchedule schedule)
 void silc_schedule_stop(SilcSchedule schedule)
 {
   SILC_LOG_DEBUG(("Stopping scheduler"));
-  silc_mutex_lock(schedule->lock);
   schedule->valid = FALSE;
-  silc_mutex_unlock(schedule->lock);
 }
 
 /* Executes nontimeout tasks. It then checks whether any of ther fd tasks