[Spice-commits] 2 commits - server/red-worker.c server/tests

Frediano Ziglio fziglio at kemper.freedesktop.org
Tue Sep 12 13:19:18 UTC 2017


 server/red-worker.c             |    1 +
 server/tests/Makefile.am        |   12 ------------
 server/tests/test-glib-compat.h |   22 ++++++++++++++++++++++
 3 files changed, 23 insertions(+), 12 deletions(-)

New commits:
commit 3dc6bc76f12d4f400b4f48985ca39adb0e23a35d
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Mon Sep 11 10:58:45 2017 +0100

    tests: Avoid to disable all deprecation warnings just for expect functions
    
    In case GLib don't provide these functions we use replacements so
    there's no need to have a warning if these functions are called.
    This potentially capture other compatibility issues in the tests
    that would be ignored having all deprecation warnings disabled.
    Tested with GLib 2.28 and 2.52.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/server/tests/Makefile.am b/server/tests/Makefile.am
index d50c590c..2efc136d 100644
--- a/server/tests/Makefile.am
+++ b/server/tests/Makefile.am
@@ -128,18 +128,6 @@ libtest_stat4_a_CPPFLAGS = $(AM_CPPFLAGS) -DTEST_COMPRESS_STAT=1 -DTEST_RED_WORK
 
 test_qxl_parsing_LDADD = ../libserver.la $(LDADD)
 
-# Fallback implementations are provided for older glibs for the recent glib
-# methods this test is using, so no need to warn about them
-test_vdagent_CPPFLAGS =			\
-	$(AM_CPPFLAGS)			\
-	-UGLIB_VERSION_MIN_REQUIRED	\
-	-UGLIB_VERSION_MAX_ALLOWED	\
-	$(NULL)
-test_codecs_parsing_CPPFLAGS = $(test_vdagent_CPPFLAGS)
-test_qxl_parsing_CPPFLAGS = $(test_vdagent_CPPFLAGS)
-test_fail_on_null_core_interface_CPPFLAGS = $(test_vdagent_CPPFLAGS)
-test_leaks_CPPFLAGS = $(test_vdagent_CPPFLAGS)
-
 if HAVE_GSTREAMER
 test_gst_SOURCES = test-gst.c \
 	$(NULL)
diff --git a/server/tests/test-glib-compat.h b/server/tests/test-glib-compat.h
index a364012f..bb0f601c 100644
--- a/server/tests/test-glib-compat.h
+++ b/server/tests/test-glib-compat.h
@@ -29,6 +29,28 @@ void g_test_assert_expected_messages_internal(const char *domain,
     g_test_assert_expected_messages_internal (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC)
 void g_test_expect_message(const gchar *log_domain, GLogLevelFlags log_level,
                            const gchar *pattern);
+#else
+/* this avoids deprecation warning */
+static inline void
+g_test_expect_message_no_warnings(const gchar *log_domain, GLogLevelFlags log_level,
+                                  const gchar *pattern)
+{
+    G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+    g_test_expect_message(log_domain, log_level, pattern);
+    G_GNUC_END_IGNORE_DEPRECATIONS
+}
+static inline void
+g_test_assert_expected_messages_internal_no_warnings(const char *domain,
+                                                     const char *file, int line, const char *func)
+{
+    G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+    g_test_assert_expected_messages_internal(domain, file, line, func);
+    G_GNUC_END_IGNORE_DEPRECATIONS
+}
+#define g_test_expect_message g_test_expect_message_no_warnings
+#define g_test_assert_expected_messages_internal g_test_assert_expected_messages_internal_no_warnings
+/* g_test_assert_expected_messages defined above is already defined for
+ * Glib >= 2.34 so we don't need to define it here */
 #endif
 
 /* GLIB_CHECK_VERSION(2, 40, 0) */
commit 08dd9c4f48e6b0af1938df075e85165c30816111
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Sat Sep 2 12:58:07 2017 +0100

    red-worker: Start processing commands as soon as possible
    
    When the worker is started it could take a while to start processing
    commands.
    The reason is that the dispatcher handler is called after the worker
    so GLib will receive a FALSE answer to both prepare and check
    callbacks of the RedWorkerSource causing GLib to wait till another
    event is received.
    This is a regression since the introduction of GLib event loop, before
    the command processing was always attempted after any events.
    Commands (from QXL interface for cursor and display) are processed
    during the RedWorkerSource dispatch so if they are not processed just
    when the VM is started they will be processed on next event which
    could be from dispatcher (main thread requests), from existing
    connections or from pending timers. However in the case there are no
    clients connected and no other requests from main thread the worker
    thread won't process them.
    Setting the event_timeout to 0 cause the prepare callback to return
    TRUE so GLib will dispatch the RedWorkerSource.
    This was discovered attempting to use the tests in server/tests
    directory to reproduce a leak in RedWorker.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/server/red-worker.c b/server/red-worker.c
index 58d9e0ad..eb7d204a 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -640,6 +640,7 @@ static void handle_dev_start(void *opaque, void *payload)
         display_channel_wait_for_migrate_data(worker->display_channel);
     }
     worker->running = TRUE;
+    worker->event_timeout = 0;
     guest_set_client_capabilities(worker);
 }
 


More information about the Spice-commits mailing list