Commit 057ef6a2 authored by Moritz Grimm's avatar Moritz Grimm
Browse files

Clean up stream before exiting

Gentle reminder by AddressSanitizer.
parent 543b4d68
...@@ -748,8 +748,10 @@ main(int argc, char *argv[]) ...@@ -748,8 +748,10 @@ main(int argc, char *argv[])
} }
main_stream = stream_create(CFG_DEFAULT); main_stream = stream_create(CFG_DEFAULT);
if (0 > stream_configure(main_stream)) if (0 > stream_configure(main_stream)) {
stream_destroy(&main_stream);
return (ez_shutdown(1)); return (ez_shutdown(1));
}
cfg_server = stream_get_cfg_server(main_stream); cfg_server = stream_get_cfg_server(main_stream);
cfg_stream = stream_get_cfg_stream(main_stream); cfg_stream = stream_get_cfg_stream(main_stream);
cfg_intake = stream_get_cfg_intake(main_stream); cfg_intake = stream_get_cfg_intake(main_stream);
...@@ -762,6 +764,7 @@ main(int argc, char *argv[]) ...@@ -762,6 +764,7 @@ main(int argc, char *argv[])
for (i = 0; i < sizeof(ezstream_signals) / sizeof(int); i++) { for (i = 0; i < sizeof(ezstream_signals) / sizeof(int); i++) {
if (sigaction(ezstream_signals[i], &act, NULL) == -1) { if (sigaction(ezstream_signals[i], &act, NULL) == -1) {
log_syserr(ERROR, errno, "sigaction"); log_syserr(ERROR, errno, "sigaction");
stream_destroy(&main_stream);
return (ez_shutdown(1)); return (ez_shutdown(1));
} }
} }
...@@ -775,6 +778,7 @@ main(int argc, char *argv[]) ...@@ -775,6 +778,7 @@ main(int argc, char *argv[])
act.sa_handler = SIG_IGN; act.sa_handler = SIG_IGN;
if (sigaction(SIGPIPE, &act, NULL) == -1) { if (sigaction(SIGPIPE, &act, NULL) == -1) {
log_syserr(ERROR, errno, "sigaction"); log_syserr(ERROR, errno, "sigaction");
stream_destroy(&main_stream);
return (ez_shutdown(1)); return (ez_shutdown(1));
} }
...@@ -783,6 +787,7 @@ main(int argc, char *argv[]) ...@@ -783,6 +787,7 @@ main(int argc, char *argv[])
if (0 > stream_connect(main_stream)) { if (0 > stream_connect(main_stream)) {
log_error("initial server connection failed"); log_error("initial server connection failed");
stream_destroy(&main_stream);
return (ez_shutdown(1)); return (ez_shutdown(1));
} }
log_notice("connected: %s://%s:%u%s", log_notice("connected: %s://%s:%u%s",
...@@ -814,6 +819,7 @@ main(int argc, char *argv[]) ...@@ -814,6 +819,7 @@ main(int argc, char *argv[])
} while (cont); } while (cont);
stream_disconnect(main_stream); stream_disconnect(main_stream);
stream_destroy(&main_stream);
if (quit) { if (quit) {
if (cfg_get_program_quiet_stderr() && if (cfg_get_program_quiet_stderr() &&
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment