X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilcutil%2Fsilcschedule.c;h=5ca563035b4aa6b3008d82a48e04da47628873ac;hb=413da0f8686910f5e627393157566ae729ca99c4;hp=a474d1651ce4c4b2cad15636a62b8b46d4462456;hpb=050bd9d9e5d843220f3f393a18ab5011622237b9;p=crypto.git diff --git a/lib/silcutil/silcschedule.c b/lib/silcutil/silcschedule.c index a474d165..5ca56303 100644 --- a/lib/silcutil/silcschedule.c +++ b/lib/silcutil/silcschedule.c @@ -344,16 +344,17 @@ 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) continue; - fd = schedule->fd_list[i].fd; - /* First check whether this fd has task in the fd queue */ 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. */ @@ -363,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, @@ -373,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, @@ -404,7 +405,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 && fd == schedule->fd_list[i].fd) { silc_mutex_unlock(schedule->generic_queue->lock); SILC_SCHEDULE_UNLOCK(schedule); @@ -415,7 +416,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 && fd == schedule->fd_list[i].fd) { silc_mutex_unlock(schedule->generic_queue->lock); SILC_SCHEDULE_UNLOCK(schedule);