From e10f00a1abc7318cb34162f7ca39eca84cfcb3a9 Mon Sep 17 00:00:00 2001 From: "hyunghwan.chung" Date: Thu, 28 Dec 2017 17:10:30 +0000 Subject: [PATCH] fixed an IO thread termination bug --- moo/kernel/Socket.moo | 1 + moo/lib/exec.c | 17 ++++++++++++----- moo/lib/main.c | 7 +++++-- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/moo/kernel/Socket.moo b/moo/kernel/Socket.moo index d01f966..9951c43 100644 --- a/moo/kernel/Socket.moo +++ b/moo/kernel/Socket.moo @@ -202,6 +202,7 @@ class MyObject(Object) while (true) { System handleAsyncEvent. + }. s close dump. diff --git a/moo/lib/exec.c b/moo/lib/exec.c index 7a48ed1..679cd37 100644 --- a/moo/lib/exec.c +++ b/moo/lib/exec.c @@ -4044,13 +4044,20 @@ static MOO_INLINE int switch_process_if_needed (moo_t* moo) switch_to_next: /* TODO: implement different process switching scheme - time-slice or clock based??? */ #if defined(MOO_EXTERNAL_PROCESS_SWITCH) - if (!moo->proc_switched && moo->switch_proc) { switch_to_next_runnable_process (moo); } - moo->switch_proc = 0; -#else - if (!moo->proc_switched) { switch_to_next_runnable_process (moo); } + if (moo->switch_proc) + { +#endif + if (!moo->proc_switched) + { + switch_to_next_runnable_process (moo); + moo->proc_switched = 0; + } +#if defined(MOO_EXTERNAL_PROCESS_SWITCH) + moo->switch_proc = 0; + } + else moo->proc_switched = 0; #endif - moo->proc_switched = 0; return 1; } diff --git a/moo/lib/main.c b/moo/lib/main.c index 5cc5996..4bcb9f3 100644 --- a/moo/lib/main.c +++ b/moo/lib/main.c @@ -1536,6 +1536,8 @@ static void vm_muxwait (moo_t* moo, const moo_ntime_t* dur, moo_vmprim_muxwait_c } } + if (xtn->iothr_abort) return; + if (xtn->ev.len <= 0) { struct timespec ts; @@ -1908,15 +1910,16 @@ static void setup_tick (void) struct itimerval itv; struct sigaction act; + memset (&act, 0, sizeof(act)); sigemptyset (&act.sa_mask); act.sa_handler = arrange_process_switching; act.sa_flags = SA_RESTART; sigaction (SIGVTALRM, &act, MOO_NULL); itv.it_interval.tv_sec = 0; - itv.it_interval.tv_usec = 100; /* 100 microseconds */ + itv.it_interval.tv_usec = 10000; /* microseconds */ itv.it_value.tv_sec = 0; - itv.it_value.tv_usec = 100; + itv.it_value.tv_usec = 10000; setitimer (ITIMER_VIRTUAL, &itv, MOO_NULL); #else