diff --git a/src/main/main.c b/src/main/main.c index 9f32cdd98..485780c04 100644 --- a/src/main/main.c +++ b/src/main/main.c @@ -1233,7 +1233,6 @@ void re_thread_leave(void) /* Dummy async event, to ensure timers are properly handled */ if (re->async) re_thread_async(NULL, NULL, NULL); - re_atomic_rlx_set(&re->thread_enter, false); re_unlock(re); } @@ -1311,8 +1310,7 @@ int re_thread_check(bool debug) if (!re) return EINVAL; - bool te = re_atomic_rlx(&re->thread_enter); - if (te) + if (re_atomic_rlx(&re->thread_enter)) return 0; if (thrd_equal(re->tid, thrd_current())) @@ -1321,7 +1319,7 @@ int re_thread_check(bool debug) if (debug) { DEBUG_WARNING( "thread check: called from a NON-RE thread without " - "thread_enter()! [thread_enter=%d]\n", te); + "thread_enter()!\n"); #if DEBUG_LEVEL > 5 struct btrace trace; diff --git a/test/remain.c b/test/remain.c index 81747f7f6..e09e16a52 100644 --- a/test/remain.c +++ b/test/remain.c @@ -146,8 +146,6 @@ static void mqueue_handler(int id, void *dat, void *arg) (void)id; (void)dat; - DEBUG_NOTICE("mqueue_handler\n"); - ++data->mqueue_called; /* Stop re_main loop */ @@ -179,21 +177,12 @@ static int enterleave_thread_handler(void *arg) static int test_remain_enterleave(void) { - /* - * re_thread_enter() and re_thread_leave() works only - * with one re poll thread (re_global). - */ - if (test_mode == TEST_THREAD) - return ESKIPPED; - struct data data = {0}; int err = thread_create_name(&data.tid, "enter-leave", enterleave_thread_handler, &data); TEST_ERR(err); - DEBUG_NOTICE("starting re_main loop..\n"); - /* run re_main event loop */ err = re_main_timeout(1000); TEST_ERR(err); @@ -214,14 +203,18 @@ int test_remain(void) { int err = 0; - if (1) { - err = test_remain_thread(); + err = test_remain_thread(); + TEST_ERR(err); + + /* + * re_thread_enter() and re_thread_leave() works only + * with one re poll thread (re_global). + */ + if (test_mode != TEST_THREAD) { + err = test_remain_enterleave(); TEST_ERR(err); } - err = test_remain_enterleave(); - TEST_ERR(err); - out: return err; }