The destructor function was calling reds_cleanup() for each server at application exit. But reds_cleanup() only cleans up a couple of statistics-related variables. We should actually free the servers by calling spice_server_destroy(). This left reds_cleanup() unused, so the contents of this function were moved inside spice_server_destroy(). --- server/reds.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/server/reds.c b/server/reds.c index eeb6010..c03ed18 100644 --- a/server/reds.c +++ b/server/reds.c @@ -2904,27 +2904,14 @@ static int reds_init_ssl(RedsState *reds) return 0; } -static void reds_cleanup(RedsState *reds) -{ -#ifdef RED_STATISTICS - if (reds->stat_shm_name) { - shm_unlink(reds->stat_shm_name); - free(reds->stat_shm_name); - reds->stat_shm_name = NULL; - } -#endif -} - SPICE_DESTRUCTOR_FUNC(reds_exit) { - GList *l; + GListIter iter; + RedsState *reds; - pthread_mutex_lock(&global_reds_lock); - for (l = servers; l != NULL; l = l->next) { - RedsState *reds = l->data; - reds_cleanup(reds); + GLIST_FOREACH(servers, iter, RedsState, reds) { + spice_server_destroy(reds); } - pthread_mutex_unlock(&global_reds_lock); } static inline void on_activating_ticketing(RedsState *reds) @@ -3695,7 +3682,14 @@ SPICE_GNUC_VISIBLE void spice_server_destroy(SpiceServer *reds) if (reds->main_channel) { main_channel_close(reds->main_channel); } - reds_cleanup(reds); + +#ifdef RED_STATISTICS + if (reds->stat_shm_name) { + shm_unlink(reds->stat_shm_name); + free(reds->stat_shm_name); + reds->stat_shm_name = NULL; + } +#endif /* remove the server from the list of servers so that we don't attempt to * free it again at exit */ -- 2.7.4 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel