[Spice-devel,v2,18/19] Free replay queues

Submitted by Frediano Ziglio on Nov. 25, 2016, 2:52 p.m.

Details

Message ID 3c8fd3171db15f48c6b4ec65be6e861f51f9767b.1480085518.git-series.fziglio@redhat.com
State Superseded
Headers show
Series "Start cleaning objects on destruction" ( rev: 4 3 2 ) in Spice

Not browsing as part of any series.

Commit Message

Frediano Ziglio Nov. 25, 2016, 2:52 p.m.
There could be still some data pending.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
---
 server/tests/replay.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/server/tests/replay.c b/server/tests/replay.c
index 23d4125..8ec65d6 100644
--- a/server/tests/replay.c
+++ b/server/tests/replay.c
@@ -302,6 +302,21 @@  static gboolean progress_timer(gpointer user_data)
     return TRUE;
 }
 
+static void free_queue(GAsyncQueue *queue)
+{
+    for (;;) {
+        QXLCommandExt *cmd = g_async_queue_try_pop(queue);
+        if (cmd == GINT_TO_POINTER(-1)) {
+            continue;
+        }
+        if (!cmd) {
+            break;
+        }
+        spice_replay_free_cmd(replay, cmd);
+    }
+    g_async_queue_unref(queue);
+}
+
 int main(int argc, char **argv)
 {
     GError *error = NULL;
@@ -440,9 +455,9 @@  int main(int argc, char **argv)
         g_print("Counted %d commands\n", ncommands);
 
     spice_server_destroy(server);
+    free_queue(display_queue);
+    free_queue(cursor_queue);
     end_replay();
-    g_async_queue_unref(display_queue);
-    g_async_queue_unref(cursor_queue);
 
     /* FIXME: there should be a way to join server threads before:
      * g_main_loop_unref(loop);

Comments

On Fri, 2016-11-25 at 14:52 +0000, Frediano Ziglio wrote:
> There could be still some data pending.
> 
> Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
> ---
>  server/tests/replay.c | 19 +++++++++++++++++--
>  1 file changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/server/tests/replay.c b/server/tests/replay.c
> index 23d4125..8ec65d6 100644
> --- a/server/tests/replay.c
> +++ b/server/tests/replay.c
> @@ -302,6 +302,21 @@ static gboolean progress_timer(gpointer
> user_data)
>      return TRUE;
>  }
>  
> +static void free_queue(GAsyncQueue *queue)
> +{
> +    for (;;) {
> +        QXLCommandExt *cmd = g_async_queue_try_pop(queue);
> +        if (cmd == GINT_TO_POINTER(-1)) {
> +            continue;
> +        }
> +        if (!cmd) {
> +            break;
> +        }
> +        spice_replay_free_cmd(replay, cmd);
> +    }
> +    g_async_queue_unref(queue);
> +}
> +
>  int main(int argc, char **argv)
>  {
>      GError *error = NULL;
> @@ -440,9 +455,9 @@ int main(int argc, char **argv)
>          g_print("Counted %d commands\n", ncommands);
>  
>      spice_server_destroy(server);
> +    free_queue(display_queue);
> +    free_queue(cursor_queue);
>      end_replay();
> -    g_async_queue_unref(display_queue);
> -    g_async_queue_unref(cursor_queue);
>  
>      /* FIXME: there should be a way to join server threads before:
>       * g_main_loop_unref(loop);