Skip to content

Commit

Permalink
main: call unloadlibs from main
Browse files Browse the repository at this point in the history
Signed-off-by: He Xian <[email protected]>
  • Loading branch information
hexian000 committed Dec 31, 2024
1 parent abc28c0 commit e32c54a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 17 deletions.
1 change: 1 addition & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ int main(int argc, char **argv)

session_closeall(loop);
ev_loop_destroy(loop);
unloadlibs();

LOGD("program terminated normally");
return EXIT_SUCCESS;
Expand Down
20 changes: 3 additions & 17 deletions src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,27 +166,13 @@ void init(int argc, char **argv)
if (sigaction(SIGPIPE, &ignore, NULL) != 0) {
FAILMSGF("sigaction: %s", strerror(errno));
}
#if WITH_CRASH_HANDLER
set_crash_handler();
#endif
}

static void unloadlibs(void);

void loadlibs(void)
{
{
static bool loaded = false;
if (loaded) {
return;
}
loaded = true;

const int ret = atexit(unloadlibs);
if (ret != 0) {
FAILMSGF("atexit: %d", ret);
}
}
#if WITH_CRASH_HANDLER
set_crash_handler();
#endif
srand64((uint64_t)time(NULL));

LOGD_F("%s: %s", PROJECT_NAME, PROJECT_VER);
Expand Down
1 change: 1 addition & 0 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ void pipe_shrink(size_t count);

void init(int argc, char **argv);
void loadlibs(void);
void unloadlibs(void);

struct user_ident {
uid_t uid;
Expand Down

0 comments on commit e32c54a

Please sign in to comment.