Skip to content

Commit

Permalink
main: add debug boolean to re_thread_check()
Browse files Browse the repository at this point in the history
  • Loading branch information
sreimers committed Apr 29, 2023
1 parent cfd7f93 commit 40a1b04
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion include/re_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ int re_thread_init(void);
void re_thread_close(void);
void re_thread_enter(void);
void re_thread_leave(void);
int re_thread_check(void);
int re_thread_check(bool debug);
int re_thread_async_init(uint16_t workers);
void re_thread_async_close(void);
int re_thread_async(re_async_work_h *work, re_async_h *cb, void *arg);
Expand Down
17 changes: 10 additions & 7 deletions src/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ int fd_listen(re_sock_t fd, int flags, fd_h *fh, void *arg)
DEBUG_INFO("fd_listen: fd=%d flags=0x%02x\n", fd, flags);

#ifndef RELEASE
err = re_thread_check();
err = re_thread_check(true);
if (err)
return err;
#endif
Expand Down Expand Up @@ -1306,7 +1306,7 @@ void re_set_mutex(void *mutexp)
*
* @return 0 if success, otherwise EPERM
*/
int re_thread_check(void)
int re_thread_check(bool debug)
{
struct re *re = re_get();

Expand All @@ -1319,14 +1319,17 @@ int re_thread_check(void)
if (thrd_equal(re->tid, thrd_current()))
return 0;

DEBUG_WARNING("thread check: called from a NON-RE thread without "
"thread_enter()!\n");
if (debug) {
DEBUG_WARNING(
"thread check: called from a NON-RE thread without "
"thread_enter()!\n");

#if DEBUG_LEVEL > 5
struct btrace trace;
btrace(&trace);
DEBUG_INFO("%H", btrace_println, &trace);
struct btrace trace;
btrace(&trace);
DEBUG_INFO("%H", btrace_println, &trace);
#endif
}

return EPERM;
}
Expand Down

1 comment on commit 40a1b04

@juha-h
Copy link
Contributor

@juha-h juha-h commented on 40a1b04 Apr 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

Please sign in to comment.