diff options
author | Alexey Yakovenko <wakeroid@gmail.com> | 2009-12-26 16:46:32 +0100 |
---|---|---|
committer | Alexey Yakovenko <wakeroid@gmail.com> | 2009-12-26 16:46:32 +0100 |
commit | 7d55aba17efb9e5158a0c8a7f4ccbdd5c8c07f06 (patch) | |
tree | de1233550a33170e6917d0b34dd0b2a1f099730a | |
parent | 36518651eda4a17fa6697930b9f63666f038030f (diff) |
improved plugin unloading (less bug-prone)
-rw-r--r-- | main.c | 15 | ||||
-rw-r--r-- | streamer.c | 5 |
2 files changed, 16 insertions, 4 deletions
@@ -544,17 +544,24 @@ main (int argc, char *argv[]) { // save config pl_save (defpl); conf_save (); + // stop receiving messages from outside server_close (); - // at this point we can simply do exit(0), but let's clean up for debugging - messagepump_free (); - p_free (); + + // stop streaming before unloading plugins streamer_free (); + + // plugins might still hood references to playitems, + // and query configuration in background + // so unload everything 1st before final cleanup + plug_unload_all (); + + // at this point we can simply do exit(0), but let's clean up for debugging codec_free_locking (); session_save (sessfile); pl_free (); conf_free (); - plug_unload_all (); + messagepump_free (); fprintf (stderr, "hej-hej!\n"); return 0; } @@ -107,6 +107,9 @@ streamer_get_playing_track (void) { // playlist must call that whenever item was removed void streamer_song_removed_notify (playItem_t *it) { + if (!mutex) { + return; // streamer is not running + } plug_trigger_event (DB_EV_TRACKDELETED, (uintptr_t)it); if (it == orig_playing_song) { orig_playing_song = NULL; @@ -492,7 +495,9 @@ streamer_free (void) { streaming_terminate = 1; thread_join (streamer_tid); mutex_free (decodemutex); + decodemutex = 0; mutex_free (mutex); + mutex = 0; } void |