Skip to content

Commit

Permalink
fix re_thread_init and add libre_cleanup()
Browse files Browse the repository at this point in the history
  • Loading branch information
sreimers committed Sep 27, 2023
1 parent 204a28a commit a86b8c0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
1 change: 1 addition & 0 deletions include/re_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ struct re_fhs *fd_close(struct re_fhs *fhs);
int fd_setsize(int maxfds);

int libre_init(void);
void libre_cleanup(void);
void libre_close(void);
void libre_exception_btrace(bool enable);

Expand Down
26 changes: 19 additions & 7 deletions src/main/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,25 +168,37 @@ int libre_init(void)
return err;
}

err = re_thread_init();
if (err)
return err;

#ifdef RE_TRACE_ENABLED
re_trace_init("re_trace.json");
err = re_trace_init("re_trace.json");
if (err)
return err;
#endif

err = re_thread_init();

return err;
return 0;
}


/**
* Close library and free up all resources
* Cleanup libre resources (call before libre_close() and tmr_debug())
*/
void libre_close(void)
void libre_cleanup(void)
{

re_thread_async_close();
#ifdef RE_TRACE_ENABLED
re_trace_close();
#endif
}


/**
* Close library and free up all resources
*/
void libre_close(void)
{
(void)fd_setsize(0);
net_sock_close();
re_thread_close();
Expand Down
3 changes: 2 additions & 1 deletion test/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ int main(int argc, char *argv[])
}

out:
re_thread_async_close();

libre_cleanup();

/* Check for open timers */
tmr_debug();
Expand Down

0 comments on commit a86b8c0

Please sign in to comment.