[commands] Rename commands_cmdloop_break to commands_base_destroy and

free commands_base after breaking the libevent loop
This commit is contained in:
chme 2016-06-11 10:00:23 +02:00
parent 5258ee712c
commit 32ac6c2ea9
8 changed files with 11 additions and 23 deletions

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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_ */

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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]);

View File

@ -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);
}