Finish real thread FSM after thread scheduler has finished.ยง
authorPekka Riikonen <priikone@silcnet.org>
Thu, 2 Nov 2006 08:07:57 +0000 (08:07 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Thu, 2 Nov 2006 08:07:57 +0000 (08:07 +0000)
lib/silcutil/silcfsm.c

index 2c95ccd19f110fdba9503f376b1508d7cd079f95..caab3380802042110925832355c5a6da2e856a15 100644 (file)
@@ -369,11 +369,9 @@ SILC_TASK_CALLBACK(silc_fsm_run)
     fsm->finished = TRUE;
 
     /* If we are thread and using real threads, the FSM thread will finish
-       in the main thread, not in the created thread. */
+       after the real thread has finished, in the main thread. */
     if (fsm->thread && fsm->real_thread) {
       silc_schedule_stop(fsm->schedule);
-      silc_schedule_task_add_timeout(app_context, silc_fsm_finish, fsm, 0, 1);
-      silc_schedule_wakeup(app_context);
       break;
     }
 
@@ -698,5 +696,10 @@ static void *silc_fsm_thread(void *context)
 
   fsm->schedule = old;
 
+  /* Finish the FSM thread in the main thread */
+  SILC_ASSERT(fsm->finished);
+  silc_schedule_task_add_timeout(fsm->schedule, silc_fsm_finish, fsm, 0, 1);
+  silc_schedule_wakeup(fsm->schedule);
+
   return NULL;
 }