Cleanup
This commit is contained in:
@ -57,7 +57,7 @@ static const char *level_keywords[] = {
|
||||
static void err(const char *restrict msg) {
|
||||
char err_buf[64];
|
||||
strerror_r(errno, err_buf, sizeof(err_buf));
|
||||
fprintf(stderr, ERR_STR "[%6s][logger] %s: %s" CLR_STR "\n", level_keywords[LOG_CRITICAL], msg, err_buf);
|
||||
fprintf(stderr, ERR_STR "[logger][%6s] %s: %s" CLR_STR "\n", level_keywords[LOG_CRITICAL], msg, err_buf);
|
||||
}
|
||||
|
||||
void logmsgf(log_lvl_t level, const char *restrict format, ...) {
|
||||
@ -82,7 +82,7 @@ void logmsgf(log_lvl_t level, const char *restrict format, ...) {
|
||||
if (!logger_alive) {
|
||||
// no logger thread running
|
||||
// simply write to stdout without synchronization
|
||||
printf("%s[%-6s][%-6s]%s%s ", color, level_keywords[level], (name != NULL) ? (char *) name : "", CLR_STR, (prefix != NULL) ? (char *) prefix : "");
|
||||
printf("%s[%-6s][%-6s]%s%s ", color, (name != NULL) ? (char *) name : "", level_keywords[level], CLR_STR, (prefix != NULL) ? (char *) prefix : "");
|
||||
vprintf(buf, args);
|
||||
printf("\n");
|
||||
} else {
|
||||
|
@ -77,6 +77,7 @@ void terminate_forcefully(int sig) {
|
||||
}
|
||||
cache_unload();
|
||||
config_unload();
|
||||
geoip_free();
|
||||
exit(2);
|
||||
}
|
||||
|
||||
@ -142,6 +143,7 @@ void terminate_gracefully(int sig) {
|
||||
info("Goodbye");
|
||||
cache_unload();
|
||||
config_unload();
|
||||
geoip_free();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@ -247,6 +249,7 @@ int main(int argc, const char *argv[]) {
|
||||
ret = cache_init();
|
||||
if (ret < 0) {
|
||||
config_unload();
|
||||
geoip_free();
|
||||
return 1;
|
||||
} else if (ret != 0) {
|
||||
children[0] = ret; // pid
|
||||
@ -272,12 +275,14 @@ int main(int argc, const char *argv[]) {
|
||||
critical("Unable to load certificate chain file: %s: %s", ERR_reason_error_string(ERR_get_error()), conf->full_chain);
|
||||
config_unload();
|
||||
cache_unload();
|
||||
geoip_free();
|
||||
return 1;
|
||||
}
|
||||
if (SSL_CTX_use_PrivateKey_file(ctx, conf->priv_key, SSL_FILETYPE_PEM) != 1) {
|
||||
critical("Unable to load private key file: %s: %s", ERR_reason_error_string(ERR_get_error()), conf->priv_key);
|
||||
config_unload();
|
||||
cache_unload();
|
||||
geoip_free();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -292,6 +297,7 @@ int main(int argc, const char *argv[]) {
|
||||
critical("Unable to listen on socket %i", i);
|
||||
config_unload();
|
||||
cache_unload();
|
||||
geoip_free();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -365,5 +371,6 @@ int main(int argc, const char *argv[]) {
|
||||
|
||||
config_unload();
|
||||
cache_unload();
|
||||
geoip_free();
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user