mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-28 15:06:02 -05:00
[-] Free events on exit (turns out event_base_free does not free them)
Credit @whatdoineed2do, ref. pr #797
This commit is contained in:
parent
0a593463b8
commit
4ab734343c
@ -1673,6 +1673,7 @@ cache_deinit(void)
|
||||
return;
|
||||
}
|
||||
|
||||
// Free event base (should free events too)
|
||||
// Free event base
|
||||
event_free(cache_daap_updateev);
|
||||
event_base_free(evbase_cache);
|
||||
}
|
||||
|
@ -166,6 +166,22 @@ send_command(struct commands_base *cmdbase, struct command *cmd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Frees the command base and closes the (internally used) pipes
|
||||
*/
|
||||
int
|
||||
commands_base_free(struct commands_base *cmdbase)
|
||||
{
|
||||
if (cmdbase->command_event)
|
||||
event_free(cmdbase->command_event);
|
||||
|
||||
close(cmdbase->command_pipe[0]);
|
||||
close(cmdbase->command_pipe[1]);
|
||||
free(cmdbase);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Creates a new command base, needs to be freed by commands_base_destroy or commands_base_free.
|
||||
*
|
||||
@ -178,12 +194,7 @@ commands_base_new(struct event_base *evbase, command_exit_cb exit_cb)
|
||||
struct commands_base *cmdbase;
|
||||
int ret;
|
||||
|
||||
cmdbase = calloc(1, sizeof(struct commands_base));
|
||||
if (!cmdbase)
|
||||
{
|
||||
DPRINTF(E_LOG, L_MAIN, "Out of memory for cmdbase\n");
|
||||
return NULL;
|
||||
}
|
||||
CHECK_NULL(L_MAIN, cmdbase = calloc(1, sizeof(struct commands_base)));
|
||||
|
||||
#ifdef HAVE_PIPE2
|
||||
ret = pipe2(cmdbase->command_pipe, O_CLOEXEC);
|
||||
@ -201,9 +212,7 @@ commands_base_new(struct event_base *evbase, command_exit_cb exit_cb)
|
||||
if (!cmdbase->command_event)
|
||||
{
|
||||
DPRINTF(E_LOG, L_MAIN, "Could not create cmd event\n");
|
||||
close(cmdbase->command_pipe[0]);
|
||||
close(cmdbase->command_pipe[1]);
|
||||
free(cmdbase);
|
||||
commands_base_free(cmdbase);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -211,9 +220,7 @@ commands_base_new(struct event_base *evbase, command_exit_cb exit_cb)
|
||||
if (ret != 0)
|
||||
{
|
||||
DPRINTF(E_LOG, L_MAIN, "Could not add cmd event\n");
|
||||
close(cmdbase->command_pipe[0]);
|
||||
close(cmdbase->command_pipe[1]);
|
||||
free(cmdbase);
|
||||
commands_base_free(cmdbase);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -223,20 +230,6 @@ commands_base_new(struct event_base *evbase, command_exit_cb exit_cb)
|
||||
return cmdbase;
|
||||
}
|
||||
|
||||
/*
|
||||
* Frees the command base and closes the (internally used) pipes
|
||||
*/
|
||||
int
|
||||
commands_base_free(struct commands_base *cmdbase)
|
||||
{
|
||||
event_free(cmdbase->command_event);
|
||||
close(cmdbase->command_pipe[0]);
|
||||
close(cmdbase->command_pipe[1]);
|
||||
free(cmdbase);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Gets the current return value for the current pending command.
|
||||
*
|
||||
|
@ -1748,7 +1748,7 @@ httpd_init(const char *webroot)
|
||||
{
|
||||
DPRINTF(E_FATAL, L_HTTPD, "Could not create exit event\n");
|
||||
|
||||
goto event_fail;
|
||||
goto exitev_fail;
|
||||
}
|
||||
event_add(exitev, NULL);
|
||||
|
||||
@ -1757,7 +1757,7 @@ httpd_init(const char *webroot)
|
||||
{
|
||||
DPRINTF(E_FATAL, L_HTTPD, "Could not create HTTP server\n");
|
||||
|
||||
goto event_fail;
|
||||
goto evhttpd_fail;
|
||||
}
|
||||
|
||||
v6enabled = cfg_getbool(cfg_getsec(cfg, "general"), "ipv6");
|
||||
@ -1819,7 +1819,9 @@ httpd_init(const char *webroot)
|
||||
thread_fail:
|
||||
bind_fail:
|
||||
evhttp_free(evhttpd);
|
||||
event_fail:
|
||||
evhttpd_fail:
|
||||
event_free(exitev);
|
||||
exitev_fail:
|
||||
#ifdef HAVE_EVENTFD
|
||||
close(exit_efd);
|
||||
#else
|
||||
@ -1899,6 +1901,7 @@ httpd_deinit(void)
|
||||
close(exit_pipe[0]);
|
||||
close(exit_pipe[1]);
|
||||
#endif
|
||||
event_free(exitev);
|
||||
evhttp_free(evhttpd);
|
||||
event_base_free(evbase_httpd);
|
||||
}
|
||||
|
@ -686,6 +686,7 @@ streaming_deinit(void)
|
||||
{
|
||||
streaming_end();
|
||||
|
||||
event_free(metaev);
|
||||
event_free(streamingev);
|
||||
streamingev = NULL;
|
||||
|
||||
|
@ -935,6 +935,8 @@ input_init(void)
|
||||
thread_fail:
|
||||
commands_base_free(cmdbase);
|
||||
input_fail:
|
||||
event_free(input_open_timeout_ev);
|
||||
event_free(input_ev);
|
||||
evbuffer_free(input_buffer.evbuf);
|
||||
event_base_free(evbase_input);
|
||||
return -1;
|
||||
@ -971,6 +973,8 @@ input_deinit(void)
|
||||
pthread_cond_destroy(&input_buffer.cond);
|
||||
pthread_mutex_destroy(&input_buffer.mutex);
|
||||
|
||||
event_free(input_open_timeout_ev);
|
||||
event_free(input_ev);
|
||||
evbuffer_free(input_buffer.evbuf);
|
||||
event_base_free(evbase_input);
|
||||
}
|
||||
|
@ -791,5 +791,6 @@ library_deinit()
|
||||
sources[i]->deinit();
|
||||
}
|
||||
|
||||
event_free(updateev);
|
||||
event_base_free(evbase_lib);
|
||||
}
|
||||
|
@ -919,6 +919,8 @@ main(int argc, char **argv)
|
||||
DPRINTF(E_LOG, L_MAIN, "Stopping gracefully\n");
|
||||
ret = EXIT_SUCCESS;
|
||||
|
||||
event_free(sig_event);
|
||||
|
||||
/*
|
||||
* On a clean shutdown, bring mDNS down first to give a chance
|
||||
* to the clients to perform a clean shutdown on their end
|
||||
@ -971,6 +973,8 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
mdns_fail:
|
||||
event_base_free(evbase_main);
|
||||
|
||||
daemon_fail:
|
||||
if (background)
|
||||
{
|
||||
|
@ -1043,7 +1043,7 @@ outputs_deinit(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
evtimer_del(outputs_deferredev);
|
||||
event_free(outputs_deferredev);
|
||||
|
||||
for (i = 0; outputs[i]; i++)
|
||||
{
|
||||
|
@ -3327,6 +3327,7 @@ player_init(void)
|
||||
outputs_deinit();
|
||||
error_evbase_free:
|
||||
commands_base_free(cmdbase);
|
||||
event_free(pb_timer_ev);
|
||||
event_base_free(evbase_player);
|
||||
#ifdef HAVE_TIMERFD
|
||||
close(pb_timer_fd);
|
||||
@ -3369,5 +3370,6 @@ player_deinit(void)
|
||||
|
||||
free(history);
|
||||
|
||||
event_free(pb_timer_ev);
|
||||
event_base_free(evbase_player);
|
||||
}
|
||||
|
@ -861,6 +861,8 @@ remote_pairing_deinit(void)
|
||||
if (remote_info)
|
||||
free_remote(remote_info);
|
||||
|
||||
event_free(pairingev);
|
||||
|
||||
#ifdef HAVE_EVENTFD
|
||||
close(pairing_efd);
|
||||
#else
|
||||
|
@ -1582,6 +1582,7 @@ spotify_init(void)
|
||||
|
||||
session_fail:
|
||||
cmd_fail:
|
||||
event_free(g_notifyev);
|
||||
evnew_fail:
|
||||
commands_base_free(cmdbase);
|
||||
event_base_free(evbase_spotify);
|
||||
@ -1625,7 +1626,8 @@ spotify_deinit(void)
|
||||
/* Release session */
|
||||
fptr_sp_session_release(g_sess);
|
||||
|
||||
/* Free event base (should free events too) */
|
||||
/* Free event base */
|
||||
event_free(g_notifyev);
|
||||
event_base_free(evbase_spotify);
|
||||
|
||||
/* Close pipes */
|
||||
|
Loading…
x
Reference in New Issue
Block a user