diff --git a/src/cache.c b/src/cache.c index d1b40517..845d967f 100644 --- a/src/cache.c +++ b/src/cache.c @@ -1658,8 +1658,8 @@ cache_deinit(void) if (!g_initialized) return; - commands_cmdloop_exit(cmdbase); g_initialized = 0; + commands_base_destroy(cmdbase); ret = pthread_join(tid_cache, NULL); if (ret != 0) @@ -1670,7 +1670,4 @@ cache_deinit(void) // Free event base (should free events too) event_base_free(evbase_cache); - - // Close pipes and free command base - commands_base_free(cmdbase); } diff --git a/src/commands.c b/src/commands.c index f5ffe935..ef198f00 100644 --- a/src/commands.c +++ b/src/commands.c @@ -379,8 +379,9 @@ cmdloop_exit(void *arg, int *retval) } void -commands_cmdloop_exit(struct commands_base *cmdbase) +commands_base_destroy(struct commands_base *cmdbase) { commands_exec_sync(cmdbase, cmdloop_exit, NULL, cmdbase); + commands_base_free(cmdbase); } diff --git a/src/commands.h b/src/commands.h index 7c831536..be1bba1a 100644 --- a/src/commands.h +++ b/src/commands.h @@ -64,6 +64,6 @@ int commands_exec_async(struct commands_base *cmdbase, command_function func, void *arg); void -commands_cmdloop_exit(struct commands_base *cmdbase); +commands_base_destroy(struct commands_base *cmdbase); #endif /* SRC_COMMANDS_H_ */ diff --git a/src/filescanner.c b/src/filescanner.c index d9b881a6..cb278f11 100644 --- a/src/filescanner.c +++ b/src/filescanner.c @@ -2032,8 +2032,8 @@ filescanner_deinit(void) { int ret; - commands_cmdloop_exit(cmdbase); scan_exit = 1; + commands_base_destroy(cmdbase); ret = pthread_join(tid_scan, NULL); if (ret != 0) @@ -2046,5 +2046,4 @@ filescanner_deinit(void) inofd_event_unset(); event_base_free(evbase_scan); - commands_base_free(cmdbase); } diff --git a/src/mpd.c b/src/mpd.c index 0cc49da2..cf1b5866 100644 --- a/src/mpd.c +++ b/src/mpd.c @@ -4782,7 +4782,7 @@ void mpd_deinit(void) return; } - commands_cmdloop_exit(cmdbase); + commands_base_destroy(cmdbase); ret = pthread_join(tid_mpd, NULL); if (ret != 0) @@ -4808,7 +4808,4 @@ void mpd_deinit(void) // Free event base (should free events too) event_base_free(evbase_mpd); - - // Close pipes and free command base - commands_base_free(cmdbase); } diff --git a/src/player.c b/src/player.c index 5e7450a9..ab948dff 100644 --- a/src/player.c +++ b/src/player.c @@ -4123,8 +4123,8 @@ player_deinit(void) { int ret; - commands_cmdloop_exit(cmdbase); player_exit = 1; + commands_base_destroy(cmdbase); ret = pthread_join(tid_player, NULL); if (ret != 0) @@ -4149,6 +4149,4 @@ player_deinit(void) outputs_deinit(); event_base_free(evbase_player); - - commands_base_free(cmdbase); } diff --git a/src/spotify.c b/src/spotify.c index 61f487dc..8b2cedb6 100644 --- a/src/spotify.c +++ b/src/spotify.c @@ -1606,6 +1606,7 @@ exit_cb() { fptr_sp_session_player_unload(g_sess); fptr_sp_session_logout(g_sess); + g_state = SPOTIFY_STATE_INACTIVE; } /* Process events when timeout expires or triggered by libspotify's notify_main_thread */ @@ -2086,7 +2087,7 @@ spotify_deinit(void) /* Send exit signal to thread (if active) */ if (g_state != SPOTIFY_STATE_INACTIVE) { - commands_cmdloop_exit(cmdbase); + commands_base_destroy(cmdbase); g_state = SPOTIFY_STATE_INACTIVE; ret = pthread_join(tid_spotify, NULL); @@ -2103,8 +2104,7 @@ spotify_deinit(void) /* Free event base (should free events too) */ event_base_free(evbase_spotify); - /* Close pipes and free command base */ - commands_base_free(cmdbase); + /* Close pipes */ close(g_notify_pipe[0]); close(g_notify_pipe[1]); diff --git a/src/worker.c b/src/worker.c index 29f99e1d..a7cc9ee7 100644 --- a/src/worker.c +++ b/src/worker.c @@ -199,7 +199,6 @@ worker_init(void) thread_fail: commands_base_free(cmdbase); - evnew_fail: event_base_free(evbase_worker); evbase_worker = NULL; @@ -212,8 +211,8 @@ worker_deinit(void) { int ret; - commands_cmdloop_exit(cmdbase); g_initialized = 0; + commands_base_destroy(cmdbase); ret = pthread_join(tid_worker, NULL); if (ret != 0) @@ -224,7 +223,4 @@ worker_deinit(void) // Free event base (should free events too) event_base_free(evbase_worker); - - // Close pipes and free command base - commands_base_free(cmdbase); }