updates.
[silc.git] / lib / silcutil / silcschedule.c
index fd53ffe237def1d36cb0e1761cbf3514a161a027..e34009b2be954d07f88b5cc54c86ed23d6f1e936 100644 (file)
@@ -277,7 +277,6 @@ static void silc_schedule_dispatch_nontimeout(SilcSchedule schedule)
     /* First check whether this fd has task in the fd queue */
     silc_mutex_lock(schedule->fd_queue->lock);
     task = silc_task_find(schedule->fd_queue, schedule->fd_list[i].fd);
-    silc_mutex_unlock(schedule->fd_queue->lock);
 
     /* If the task was found then execute its callbacks. If not then
        execute all generic tasks for that fd. */
@@ -285,7 +284,6 @@ static void silc_schedule_dispatch_nontimeout(SilcSchedule schedule)
       /* Validity of the task is checked always before and after
         execution beacuse the task might have been unregistered
         in the callback function, ie. it is not valid anymore. */
-      silc_mutex_lock(schedule->fd_queue->lock);
 
       /* Is the task ready for reading */
       if (task->valid && schedule->fd_list[i].revents & SILC_TASK_READ) {
@@ -312,6 +310,8 @@ static void silc_schedule_dispatch_nontimeout(SilcSchedule schedule)
     } else {
       /* Run generic tasks for this fd. */
 
+      silc_mutex_unlock(schedule->fd_queue->lock);
+
       silc_mutex_lock(schedule->generic_queue->lock);
       if (!schedule->generic_queue->task) {
        silc_mutex_unlock(schedule->generic_queue->lock);