Put the fd check back to generic task dispatching.
authorPekka Riikonen <priikone@silcnet.org>
Mon, 6 Oct 2003 08:00:23 +0000 (08:00 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Mon, 6 Oct 2003 08:00:23 +0000 (08:00 +0000)
lib/silcutil/silcschedule.c

index 31a5a98286c800fa9915bed4ad55624a4041c955..5ca563035b4aa6b3008d82a48e04da47628873ac 100644 (file)
@@ -344,6 +344,7 @@ static void silc_schedule_dispatch_nontimeout(SilcSchedule schedule)
   SilcTask task;
   int i;
   SilcUInt32 fd, last_fd = schedule->last_fd;
+  SilcUInt16 revents;
 
   for (i = 0; i <= last_fd; i++) {
     if (schedule->fd_list[i].events == 0)
@@ -353,6 +354,7 @@ static void silc_schedule_dispatch_nontimeout(SilcSchedule schedule)
     silc_mutex_lock(schedule->fd_queue->lock);
     fd = schedule->fd_list[i].fd;
     task = silc_task_find(schedule->fd_queue, fd);
+    revents = schedule->fd_list[i].revents;
 
     /* If the task was found then execute its callbacks. If not then
        execute all generic tasks for that fd. */
@@ -362,7 +364,7 @@ static void silc_schedule_dispatch_nontimeout(SilcSchedule schedule)
         in the callback function, ie. it is not valid anymore. */
 
       /* Is the task ready for reading */
-      if (task->valid && schedule->fd_list[i].revents & SILC_TASK_READ) {
+      if (task->valid && revents & SILC_TASK_READ) {
        silc_mutex_unlock(schedule->fd_queue->lock);
        SILC_SCHEDULE_UNLOCK(schedule);
        task->callback(schedule, schedule->app_context,
@@ -372,7 +374,7 @@ 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 && revents & SILC_TASK_WRITE) {
        silc_mutex_unlock(schedule->fd_queue->lock);
        SILC_SCHEDULE_UNLOCK(schedule);
        task->callback(schedule, schedule->app_context,
@@ -403,7 +405,8 @@ static void silc_schedule_dispatch_nontimeout(SilcSchedule schedule)
           in the callback function, ie. it is not valid anymore. */
 
        /* Is the task ready for reading */                             
-       if (task->valid && schedule->fd_list[i].revents & SILC_TASK_READ) {
+       if (task->valid && revents & SILC_TASK_READ &&
+           fd == schedule->fd_list[i].fd) {
          silc_mutex_unlock(schedule->generic_queue->lock);
          SILC_SCHEDULE_UNLOCK(schedule);
          task->callback(schedule, schedule->app_context,
@@ -413,7 +416,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 && 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,