diff --git a/common.c b/common.c index dbbbef60..63ea1cd4 100644 --- a/common.c +++ b/common.c @@ -112,7 +112,6 @@ void set_alsa_out_dev(char *); config_t config_file_stuff; int type_of_exit_cleanup; -pthread_t main_thread_id; uint64_t ns_time_at_startup, ns_time_at_last_debug_message; // always lock use this when accessing the ns_time_at_last_debug_message diff --git a/common.h b/common.h index 0d5ae2e7..a3f21126 100644 --- a/common.h +++ b/common.h @@ -37,7 +37,7 @@ typedef enum { typedef enum { TOE_normal, TOE_emergency, - TOE_dbus // a dbus request was made -- don't wait for the dbus thread to exit + TOE_dbus // a request was made on a D-Bus interface (the native D-Bus or MPRIS interfaces)-- don't wait for the dbus thread to exit } type_of_exit_type; #define sps_extra_code_output_stalled 32768 @@ -401,9 +401,6 @@ extern uint64_t ns_time_at_startup, ns_time_at_last_debug_message; uint32_t uatoi(const char *nptr); -// this is for allowing us to cancel the whole program -extern pthread_t main_thread_id; - extern shairport_cfg config; extern config_t config_file_stuff; extern int type_of_exit_cleanup; // normal, emergency, dbus requested... diff --git a/mpris-service.c b/mpris-service.c index 9851f0b7..8416df95 100644 --- a/mpris-service.c +++ b/mpris-service.c @@ -229,7 +229,8 @@ void mpris_metadata_watcher(struct metadata_bundle *argc, __attribute__((unused) static gboolean on_handle_quit(MediaPlayer2 *skeleton, GDBusMethodInvocation *invocation, __attribute__((unused)) gpointer user_data) { debug(1, "quit requested (MPRIS interface)."); - pthread_cancel(main_thread_id); + type_of_exit_cleanup = TOE_dbus; // request an exit cleanup that is compatible with dbus + exit(EXIT_SUCCESS); media_player2_complete_quit(skeleton, invocation); return TRUE; } diff --git a/shairport.c b/shairport.c index 9f3ce855..f4c7f25d 100644 --- a/shairport.c +++ b/shairport.c @@ -599,6 +599,9 @@ int parse_options(int argc, char **argv) { 1); // allow autoconversion from int/float to int/float // make config.cfg point to it config.cfg = &config_file_stuff; + + config_write(config.cfg, stderr); + /* Get the Service Name. */ if (config_lookup_string(config.cfg, "general.name", &str)) { raw_service_name = (char *)str; @@ -1734,7 +1737,6 @@ int main(int argc, char **argv) { pid = getpid(); config.log_fd = -1; conns = NULL; // no connections active - memset((void *)&main_thread_id, 0, sizeof(main_thread_id)); ns_time_at_startup = get_absolute_time_in_ns(); ns_time_at_last_debug_message = ns_time_at_startup; // this is a bit weird, but necessary -- basename() may modify the argument passed in @@ -2053,10 +2055,6 @@ int main(int argc, char **argv) { exit(1); } - main_thread_id = pthread_self(); - if (!main_thread_id) - debug(1, "Main thread is set up to be NULL!"); - // make sure the program can create files that group and world can read umask(S_IWGRP | S_IWOTH);