Check that fd is valid in generic task queues before calling
authorPekka Riikonen <priikone@silcnet.org>
Thu, 16 Jan 2003 17:43:58 +0000 (17:43 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Thu, 16 Jan 2003 17:43:58 +0000 (17:43 +0000)
the callback.

lib/silcutil/silcschedule.c

index e0f658b08f52807e42fa93107a14f107155bbf59..ff47e29462f6e5bb49e428ba082a8d689d983a45 100644 (file)
@@ -399,7 +399,7 @@ static void silc_schedule_dispatch_nontimeout(SilcSchedule schedule)
 
       task = schedule->generic_queue->task;
       while(1) {
-       /* Validity of the task is checked always before and after
+       /* Validity of the task and fd is checked always before and after
           execution beacuse the task might have been unregistered
           in the callback function, ie. it is not valid anymore. */
 
@@ -414,7 +414,8 @@ static void silc_schedule_dispatch_nontimeout(SilcSchedule schedule)
        }
 
        /* Is the task ready for writing */                             
-       if (task->valid && schedule->fd_list[i].revents & SILC_TASK_WRITE) {
+       if (task->valid && schedule->fd_list[i].revents & SILC_TASK_WRITE &&
+           fd == schedule->fd_list[i].fd) {
          silc_mutex_unlock(schedule->generic_queue->lock);
          SILC_SCHEDULE_UNLOCK(schedule);
          task->callback(schedule, schedule->app_context,