From 9cc92312680c1cccf11c159214e88a415e8a5184 Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Thu, 16 Jan 2003 17:43:58 +0000 Subject: [PATCH] Check that fd is valid in generic task queues before calling the callback. --- lib/silcutil/silcschedule.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/silcutil/silcschedule.c b/lib/silcutil/silcschedule.c index e0f658b0..ff47e294 100644 --- a/lib/silcutil/silcschedule.c +++ b/lib/silcutil/silcschedule.c @@ -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, -- 2.43.0