projects
/
silc.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added SILC Thread Queue API
[silc.git]
/
lib
/
silcutil
/
silcfsm.c
diff --git
a/lib/silcutil/silcfsm.c
b/lib/silcutil/silcfsm.c
index 4ff23bab02fdb2b8eb60678629e136c9c3e5c28e..2ded983253aa77906cd439210b69306afe92116c 100644
(file)
--- a/
lib/silcutil/silcfsm.c
+++ b/
lib/silcutil/silcfsm.c
@@
-59,8
+59,11
@@
SilcBool silc_fsm_init(SilcFSM fsm,
SilcSchedule schedule)
{
if (!schedule) {
SilcSchedule schedule)
{
if (!schedule) {
- silc_set_errno(SILC_ERR_INVALID_ARGUMENT);
- return FALSE;
+ schedule = silc_schedule_get_global();
+ if (!schedule) {
+ silc_set_errno(SILC_ERR_INVALID_ARGUMENT);
+ return FALSE;
+ }
}
fsm->fsm_context = fsm_context;
}
fsm->fsm_context = fsm_context;
@@
-767,12
+770,15
@@
void *silc_fsm_thread(void *context)
/* 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. */
/* 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;
}
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))) {
/* Start the FSM thread */
if (silc_unlikely(!silc_schedule_task_add_timeout(fsm->schedule,
silc_fsm_run, fsm, 0, 0))) {
@@
-784,6
+790,9
@@
void *silc_fsm_thread(void *context)
/* Run the scheduler */
silc_schedule(fsm->schedule);
/* Run the scheduler */
silc_schedule(fsm->schedule);
+ /* Reset global scheduler */
+ silc_schedule_set_global(NULL);
+
/* Free resources */
silc_schedule_uninit(fsm->schedule);
/* Free resources */
silc_schedule_uninit(fsm->schedule);