Skip to content

Commit

Permalink
more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
alfredh committed Sep 7, 2023
1 parent ec50d96 commit 2542492
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 20 deletions.
6 changes: 2 additions & 4 deletions src/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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()))
Expand All @@ -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;
Expand Down
25 changes: 9 additions & 16 deletions test/remain.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
Expand All @@ -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;
}

0 comments on commit 2542492

Please sign in to comment.