fix memory leak

This commit is contained in:
Nick Peng
2018-06-12 22:08:24 +08:00
parent 8cd0edad4a
commit 35f945759d
7 changed files with 766 additions and 621 deletions

View File

@@ -161,14 +161,23 @@ int smartdns_run()
void smartdns_exit()
{
fast_ping_exit();
dns_client_exit();
dns_server_exit();
dns_client_exit();
fast_ping_exit();
tlog_exit();
}
void sig_handle(int sig)
{
switch (sig) {
case SIGINT:
dns_server_stop();
return;
break;
default:
break;
}
tlog(TLOG_ERROR, "process exit.\n");
_exit(0);
}
@@ -177,13 +186,16 @@ int main(int argc, char *argv[])
{
int ret;
atexit(smartdns_exit);
signal(SIGABRT, sig_handle);
ret = smartdns_init();
if (ret != 0) {
goto errout;
}
signal(SIGINT, sig_handle);
atexit(smartdns_exit);
return smartdns_run();
errout: