Skip to content

Commit

Permalink
clean up debug
Browse files Browse the repository at this point in the history
  • Loading branch information
alfredh committed Sep 7, 2023
1 parent 0083702 commit ec50d96
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
13 changes: 1 addition & 12 deletions src/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1202,8 +1202,6 @@ void re_thread_close(void)
*/
void re_thread_enter(void)
{
DEBUG_NOTICE("re_thread_enter\n");

struct re *re = re_get();

if (!re) {
Expand All @@ -1215,8 +1213,6 @@ void re_thread_enter(void)

/* set only for non-re threads */
if (!thrd_equal(re->tid, thrd_current())) {
DEBUG_NOTICE("re_thread_enter:"
" setting THREAD_ENTER to True\n");
re_atomic_rlx_set(&re->thread_enter, true);
}
}
Expand All @@ -1238,9 +1234,7 @@ void re_thread_leave(void)
if (re->async)
re_thread_async(NULL, NULL, NULL);

DEBUG_NOTICE("re_thread_leave: setting THREAD_ENTER to false\n");
re_atomic_rlx_set(&re->thread_enter, false);

re_unlock(re);
}

Expand Down Expand Up @@ -1321,18 +1315,13 @@ int re_thread_check(bool debug)
if (te)
return 0;

thrd_t cur = thrd_current();
bool eq = 0 != thrd_equal(re->tid, cur);
if (eq)
if (thrd_equal(re->tid, thrd_current()))
return 0;

if (debug) {
DEBUG_WARNING(
"thread check: called from a NON-RE thread without "
"thread_enter()! [thread_enter=%d]\n", te);
fprintf(stderr, ".... tid=%zu\n", (size_t)re->tid);
fprintf(stderr, ".... cur=%zu\n", (size_t)cur);
re_printf("%H\n", re_debug, NULL);

#if DEBUG_LEVEL > 5
struct btrace trace;
Expand Down
12 changes: 4 additions & 8 deletions test/remain.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,12 @@ static void mqueue_handler(int id, void *dat, void *arg)
static int enterleave_thread_handler(void *arg)
{
struct data *data = arg;
int err;

DEBUG_NOTICE("thread start\n");

/* Enter an 're' thread */
re_thread_enter();

/* note: allocated from this thread */
err = mqueue_alloc(&data->mq, mqueue_handler, data);
int err = mqueue_alloc(&data->mq, mqueue_handler, data);

/* Leave an 're' thread */
re_thread_leave();
Expand All @@ -176,8 +173,6 @@ static int enterleave_thread_handler(void *arg)

err = mqueue_push(data->mq, 0, NULL);

DEBUG_NOTICE("thread stop\n");

return err;
}

Expand Down Expand Up @@ -206,6 +201,7 @@ static int test_remain_enterleave(void)
/* wait for thread to end */
thrd_join(data.tid, &err);

TEST_EQUALS(0, data.tmr_called);
TEST_EQUALS(1, data.mqueue_called);

out:
Expand All @@ -218,9 +214,9 @@ int test_remain(void)
{
int err = 0;

if (0) {
if (1) {
err = test_remain_thread();
TEST_ERR(err);
TEST_ERR(err);
}

err = test_remain_enterleave();
Expand Down

0 comments on commit ec50d96

Please sign in to comment.