Free statistic file on spice_server_destroy

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
This commit is contained in:
Frediano Ziglio 2016-11-17 17:38:52 +00:00
parent 29d6642430
commit 47f56a72e0
4 changed files with 24 additions and 0 deletions

View File

@ -3599,6 +3599,10 @@ SPICE_GNUC_VISIBLE void spice_server_destroy(SpiceServer *reds)
pthread_mutex_lock(&global_reds_lock);
servers = g_list_remove(servers, reds);
pthread_mutex_unlock(&global_reds_lock);
#ifdef RED_STATISTICS
stat_file_free(reds->stat_file);
#endif
}
SPICE_GNUC_VISIBLE spice_compat_version_t spice_get_current_compat_version(void)

View File

@ -80,6 +80,23 @@ cleanup:
return NULL;
}
void stat_file_free(RedStatFile *stat_file)
{
if (!stat_file) {
return;
}
stat_file_unlink(stat_file);
/* TODO other part of the code is not ready for this! */
#if 0
size_t shm_size = STAT_SHM_SIZE(stat_file->max_nodes);
munmap(stat_file->stat, shm_size);
#endif
pthread_mutex_destroy(&stat_file->lock);
free(stat_file);
}
const char *stat_file_get_shm_name(RedStatFile *stat_file)
{
return stat_file->shm_name;

View File

@ -27,6 +27,7 @@ typedef uint32_t StatNodeRef;
typedef struct RedStatFile RedStatFile;
RedStatFile *stat_file_new(unsigned int max_nodes);
void stat_file_free(RedStatFile *stat_file);
void stat_file_unlink(RedStatFile *file_stat);
const char *stat_file_get_shm_name(RedStatFile *stat_file);
StatNodeRef stat_file_add_node(RedStatFile *stat_file, StatNodeRef parent,

View File

@ -93,6 +93,8 @@ static void stat_file(void)
g_assert_null(stat_file_get_shm_name(stat_file));
g_assert_cmpint(access(filename, F_OK),==,-1);
free(filename);
stat_file_free(stat_file);
}
int main(int argc, char *argv[])