[Spice-commits] 3 commits - server/reds.c server/stat-file.c server/stat-file.h server/tests

Frediano Ziglio fziglio at kemper.freedesktop.org
Wed Nov 30 12:38:57 UTC 2016


 server/reds.c                 |    9 +++++++++
 server/stat-file.c            |   17 +++++++++++++++++
 server/stat-file.h            |    1 +
 server/tests/test-stat-file.c |    2 ++
 4 files changed, 29 insertions(+)

New commits:
commit 38ca3467bdb445cfae546388c7a2a575628b4408
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Fri Nov 18 12:45:49 2016 +0000

    Do not leak mig_timer
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Pavel Grunt <pgrunt at redhat.com>

diff --git a/server/reds.c b/server/reds.c
index c5e84ec..f88c5f2 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -3594,6 +3594,10 @@ SPICE_GNUC_VISIBLE void spice_server_destroy(SpiceServer *reds)
     }
     reds_cleanup(reds);
 
+    if (reds->mig_timer) {
+        reds_core_timer_remove(reds, reds->mig_timer);
+    }
+
     /* remove the server from the list of servers so that we don't attempt to
      * free it again at exit */
     pthread_mutex_lock(&global_reds_lock);
commit af58d24f9b62f0f86030c6b27aec9c5d47826111
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Thu Nov 17 17:40:12 2016 +0000

    Free state on spice_server_destroy
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Pavel Grunt <pgrunt at redhat.com>

diff --git a/server/reds.c b/server/reds.c
index 1b1c737..c5e84ec 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -3603,6 +3603,7 @@ SPICE_GNUC_VISIBLE void spice_server_destroy(SpiceServer *reds)
 #ifdef RED_STATISTICS
     stat_file_free(reds->stat_file);
 #endif
+    free(reds);
 }
 
 SPICE_GNUC_VISIBLE spice_compat_version_t spice_get_current_compat_version(void)
commit 47f56a72e03ad75def06ecac3061429c2b8cee29
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Thu Nov 17 17:38:52 2016 +0000

    Free statistic file on spice_server_destroy
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Pavel Grunt <pgrunt at redhat.com>

diff --git a/server/reds.c b/server/reds.c
index 0e68973..1b1c737 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -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)
diff --git a/server/stat-file.c b/server/stat-file.c
index d1e25ce..beed77a 100644
--- a/server/stat-file.c
+++ b/server/stat-file.c
@@ -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;
diff --git a/server/stat-file.h b/server/stat-file.h
index 903b68b..0454e2e 100644
--- a/server/stat-file.h
+++ b/server/stat-file.h
@@ -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,
diff --git a/server/tests/test-stat-file.c b/server/tests/test-stat-file.c
index 09b0c7a..40cf37d 100644
--- a/server/tests/test-stat-file.c
+++ b/server/tests/test-stat-file.c
@@ -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[])


More information about the Spice-commits mailing list