Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2005 - 2007 Pekka Riikonen
+ Copyright (C) 2005 - 2008 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
*/
-#include "silc.h"
+#include "silcruntime.h"
SILC_TASK_CALLBACK(silc_fsm_run);
SILC_TASK_CALLBACK(silc_fsm_finish_fsm);
/* We allocate new SilcSchedule for the FSM, as the old SilcSchedule
cannot be used in this thread. Application may still use it if it
wants but we use our own. */
- fsm->schedule = silc_schedule_init(0, old, silc_schedule_get_stack(old));
+ fsm->schedule = silc_schedule_init(0, old, silc_schedule_get_stack(old), old);
if (silc_unlikely(!fsm->schedule)) {
fsm->schedule = old;
return NULL;
}
+ /* The new scheduler is a global scheduler in this thread */
+ silc_schedule_set_global(fsm->schedule);
+
/* Start the FSM thread */
if (silc_unlikely(!silc_schedule_task_add_timeout(fsm->schedule,
silc_fsm_run, fsm, 0, 0))) {
/* Run the scheduler */
silc_schedule(fsm->schedule);
+ /* Reset global scheduler */
+ silc_schedule_set_global(NULL);
+
/* Free resources */
silc_schedule_uninit(fsm->schedule);