[PATCH v2] Remove core_public and core_interface_adapter globals usage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Avoid not constant globals.

Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 server/event-loop.c             | 23 ++++++-----
 server/red-channel.c            | 59 +++++++++++++++------------
 server/red-common.h             | 17 ++++----
 server/reds-private.h           |  2 +-
 server/reds.c                   | 88 ++++++++++++++++++-----------------------
 server/tests/basic_event_loop.c | 37 ++++++++++++++---
 6 files changed, 129 insertions(+), 97 deletions(-)

Changes from v1:
- remove some hacks and macro usages.

diff --git a/server/event-loop.c b/server/event-loop.c
index 1b57460..4a42616 100644
--- a/server/event-loop.c
+++ b/server/event-loop.c
@@ -53,7 +53,8 @@ static gboolean timer_func(gpointer user_data)
     return FALSE;
 }
 
-static void timer_cancel(SpiceTimer *timer)
+static void timer_cancel(const SpiceCoreInterfaceInternal *iface,
+                         SpiceTimer *timer)
 {
     if (timer->source) {
         g_source_destroy(timer->source);
@@ -62,9 +63,10 @@ static void timer_cancel(SpiceTimer *timer)
     }
 }
 
-static void timer_start(SpiceTimer *timer, uint32_t ms)
+static void timer_start(const SpiceCoreInterfaceInternal *iface,
+                        SpiceTimer *timer, uint32_t ms)
 {
-    timer_cancel(timer);
+    timer_cancel(iface, timer);
 
     timer->source = g_timeout_source_new(ms);
     spice_assert(timer->source != NULL);
@@ -74,9 +76,10 @@ static void timer_start(SpiceTimer *timer, uint32_t ms)
     g_source_attach(timer->source, timer->context);
 }
 
-static void timer_remove(SpiceTimer *timer)
+static void timer_remove(const SpiceCoreInterfaceInternal *iface,
+                         SpiceTimer *timer)
 {
-    timer_cancel(timer);
+    timer_cancel(iface, timer);
     spice_assert(timer->source == NULL);
     free(timer);
 }
@@ -124,7 +127,8 @@ static gboolean watch_func(GIOChannel *source, GIOCondition condition,
     return TRUE;
 }
 
-static void watch_update_mask(SpiceWatch *watch, int event_mask)
+static void watch_update_mask(const SpiceCoreInterfaceInternal *iface,
+                              SpiceWatch *watch, int event_mask)
 {
     if (watch->source) {
         g_source_destroy(watch->source);
@@ -154,14 +158,15 @@ static SpiceWatch *watch_add(const SpiceCoreInterfaceInternal *iface,
     watch->func = func;
     watch->opaque = opaque;
 
-    watch_update_mask(watch, event_mask);
+    watch_update_mask(iface, watch, event_mask);
 
     return watch;
 }
 
-static void watch_remove(SpiceWatch *watch)
+static void watch_remove(const SpiceCoreInterfaceInternal *iface,
+                         SpiceWatch *watch)
 {
-    watch_update_mask(watch, 0);
+    watch_update_mask(iface, watch, 0);
     spice_assert(watch->source == NULL);
 
     g_io_channel_unref(watch->channel);
diff --git a/server/red-channel.c b/server/red-channel.c
index a02c51a..fffbe24 100644
--- a/server/red-channel.c
+++ b/server/red-channel.c
@@ -431,9 +431,10 @@ static void red_channel_client_on_out_block(void *opaque)
     RedChannelClient *rcc = (RedChannelClient *)opaque;
 
     rcc->send_data.blocked = TRUE;
-    rcc->channel->core->watch_update_mask(rcc->stream->watch,
-                                     SPICE_WATCH_EVENT_READ |
-                                     SPICE_WATCH_EVENT_WRITE);
+    rcc->channel->core->watch_update_mask(rcc->channel->core,
+                                          rcc->stream->watch,
+                                          SPICE_WATCH_EVENT_READ |
+                                          SPICE_WATCH_EVENT_WRITE);
 }
 
 static inline int red_channel_client_urgent_marshaller_is_active(RedChannelClient *rcc)
@@ -611,8 +612,9 @@ static void red_channel_client_on_out_msg_done(void *opaque)
     red_channel_client_release_sent_item(rcc);
     if (rcc->send_data.blocked) {
         rcc->send_data.blocked = FALSE;
-        rcc->channel->core->watch_update_mask(rcc->stream->watch,
-                                         SPICE_WATCH_EVENT_READ);
+        rcc->channel->core->watch_update_mask(rcc->channel->core,
+                                              rcc->stream->watch,
+                                              SPICE_WATCH_EVENT_READ);
     }
 
     if (red_channel_client_urgent_marshaller_is_active(rcc)) {
@@ -795,7 +797,8 @@ static void red_channel_client_connectivity_timer(void *opaque)
         } else {
              monitor->state = CONNECTIVITY_STATE_CONNECTED;
         }
-        rcc->channel->core->timer_start(rcc->connectivity_monitor.timer,
+        rcc->channel->core->timer_start(rcc->channel->core,
+                                        rcc->connectivity_monitor.timer,
                                         rcc->connectivity_monitor.timeout);
     } else {
         monitor->state = CONNECTIVITY_STATE_DISCONNECTED;
@@ -832,7 +835,8 @@ void red_channel_client_start_connectivity_monitoring(RedChannelClient *rcc, uin
             rcc->channel->core, red_channel_client_connectivity_timer, rcc);
         rcc->connectivity_monitor.timeout = timeout_ms;
         if (!red_client_during_migrate_at_target(rcc->client)) {
-           rcc->channel->core->timer_start(rcc->connectivity_monitor.timer,
+           rcc->channel->core->timer_start(rcc->channel->core,
+                                           rcc->connectivity_monitor.timer,
                                            rcc->connectivity_monitor.timeout);
         }
     }
@@ -895,9 +899,9 @@ RedChannelClient *red_channel_client_create(int size, RedChannel *channel, RedCl
     rcc->pipe_size = 0;
 
     stream->watch = channel->core->watch_add(channel->core,
-                                           stream->socket,
-                                           SPICE_WATCH_EVENT_READ,
-                                           red_channel_client_event, rcc);
+                                             stream->socket,
+                                             SPICE_WATCH_EVENT_READ,
+                                             red_channel_client_event, rcc);
     rcc->id = g_list_length(channel->clients);
     red_channel_add_client(channel, rcc);
     red_client_add_channel(client, rcc);
@@ -953,7 +957,8 @@ static void red_channel_client_seamless_migration_done(RedChannelClient *rcc)
             red_channel_client_start_ping_timer(rcc, PING_TEST_IDLE_NET_TIMEOUT_MS);
         }
         if (rcc->connectivity_monitor.timer) {
-            rcc->channel->core->timer_start(rcc->connectivity_monitor.timer,
+            rcc->channel->core->timer_start(rcc->channel->core,
+                                            rcc->connectivity_monitor.timer,
                                             rcc->connectivity_monitor.timeout);
         }
     }
@@ -999,11 +1004,11 @@ void red_channel_client_default_migrate(RedChannelClient *rcc)
 {
     if (rcc->latency_monitor.timer) {
         red_channel_client_cancel_ping_timer(rcc);
-        rcc->channel->core->timer_remove(rcc->latency_monitor.timer);
+        rcc->channel->core->timer_remove(rcc->channel->core, rcc->latency_monitor.timer);
         rcc->latency_monitor.timer = NULL;
     }
     if (rcc->connectivity_monitor.timer) {
-       rcc->channel->core->timer_remove(rcc->connectivity_monitor.timer);
+       rcc->channel->core->timer_remove(rcc->channel->core, rcc->connectivity_monitor.timer);
         rcc->connectivity_monitor.timer = NULL;
     }
     red_channel_client_pipe_add_type(rcc, RED_PIPE_ITEM_TYPE_MIGRATE);
@@ -1069,7 +1074,8 @@ RedChannel *red_channel_create(int size,
 }
 
 // TODO: red_worker can use this one
-static void dummy_watch_update_mask(SpiceWatch *watch, int event_mask)
+static void dummy_watch_update_mask(const SpiceCoreInterfaceInternal *iface,
+                                    SpiceWatch *watch, int event_mask)
 {
 }
 
@@ -1079,7 +1085,8 @@ static SpiceWatch *dummy_watch_add(const SpiceCoreInterfaceInternal *iface,
     return NULL; // apparently allowed?
 }
 
-static void dummy_watch_remove(SpiceWatch *watch)
+static void dummy_watch_remove(const SpiceCoreInterfaceInternal *iface,
+                               SpiceWatch *watch)
 {
 }
 
@@ -1279,7 +1286,7 @@ void red_channel_destroy(RedChannel *channel)
 void red_channel_client_shutdown(RedChannelClient *rcc)
 {
     if (rcc->stream && !rcc->stream->shutdown) {
-        rcc->channel->core->watch_remove(rcc->stream->watch);
+        rcc->channel->core->watch_remove(rcc->channel->core, rcc->stream->watch);
         rcc->stream->watch = NULL;
         shutdown(rcc->stream->socket, SHUT_RDWR);
         rcc->stream->shutdown = TRUE;
@@ -1341,7 +1348,8 @@ void red_channel_client_push(RedChannelClient *rcc)
     }
     if (red_channel_client_no_item_being_sent(rcc) && ring_is_empty(&rcc->pipe)
         && rcc->stream->watch) {
-        rcc->channel->core->watch_update_mask(rcc->stream->watch,
+        rcc->channel->core->watch_update_mask(rcc->channel->core,
+                                              rcc->stream->watch,
                                               SPICE_WATCH_EVENT_READ);
     }
     rcc->during_send = FALSE;
@@ -1436,7 +1444,7 @@ static void red_channel_client_start_ping_timer(RedChannelClient *rcc, uint32_t
         return;
     }
     rcc->latency_monitor.state = PING_STATE_TIMER;
-    rcc->channel->core->timer_start(rcc->latency_monitor.timer, timeout);
+    rcc->channel->core->timer_start(rcc->channel->core, rcc->latency_monitor.timer, timeout);
 }
 
 static void red_channel_client_cancel_ping_timer(RedChannelClient *rcc)
@@ -1448,7 +1456,7 @@ static void red_channel_client_cancel_ping_timer(RedChannelClient *rcc)
         return;
     }
 
-    rcc->channel->core->timer_cancel(rcc->latency_monitor.timer);
+    rcc->channel->core->timer_cancel(rcc->channel->core, rcc->latency_monitor.timer);
     rcc->latency_monitor.state = PING_STATE_NONE;
 }
 
@@ -1635,9 +1643,10 @@ static inline gboolean client_pipe_add(RedChannelClient *rcc, RedPipeItem *item,
         return FALSE;
     }
     if (ring_is_empty(&rcc->pipe) && rcc->stream->watch) {
-        rcc->channel->core->watch_update_mask(rcc->stream->watch,
-                                         SPICE_WATCH_EVENT_READ |
-                                         SPICE_WATCH_EVENT_WRITE);
+        rcc->channel->core->watch_update_mask(rcc->channel->core,
+                                              rcc->stream->watch,
+                                              SPICE_WATCH_EVENT_READ |
+                                              SPICE_WATCH_EVENT_WRITE);
     }
     rcc->pipe_size++;
     ring_add(pos, &item->link);
@@ -1823,15 +1832,15 @@ void red_channel_client_disconnect(RedChannelClient *rcc)
                    rcc->channel->type, rcc->channel->id);
     red_channel_client_pipe_clear(rcc);
     if (rcc->stream->watch) {
-        rcc->channel->core->watch_remove(rcc->stream->watch);
+        rcc->channel->core->watch_remove(rcc->channel->core, rcc->stream->watch);
         rcc->stream->watch = NULL;
     }
     if (rcc->latency_monitor.timer) {
-        rcc->channel->core->timer_remove(rcc->latency_monitor.timer);
+        rcc->channel->core->timer_remove(rcc->channel->core, rcc->latency_monitor.timer);
         rcc->latency_monitor.timer = NULL;
     }
     if (rcc->connectivity_monitor.timer) {
-        rcc->channel->core->timer_remove(rcc->connectivity_monitor.timer);
+        rcc->channel->core->timer_remove(rcc->channel->core, rcc->connectivity_monitor.timer);
         rcc->connectivity_monitor.timer = NULL;
     }
     red_channel_remove_client(rcc);
diff --git a/server/red-common.h b/server/red-common.h
index 7ab7e15..18e85f1 100644
--- a/server/red-common.h
+++ b/server/red-common.h
@@ -45,17 +45,20 @@ typedef struct SpiceCoreInterfaceInternal SpiceCoreInterfaceInternal;
 
 struct SpiceCoreInterfaceInternal {
     SpiceTimer *(*timer_add)(const SpiceCoreInterfaceInternal *iface, SpiceTimerFunc func, void *opaque);
-    void (*timer_start)(SpiceTimer *timer, uint32_t ms);
-    void (*timer_cancel)(SpiceTimer *timer);
-    void (*timer_remove)(SpiceTimer *timer);
+    void (*timer_start)(const SpiceCoreInterfaceInternal *iface, SpiceTimer *timer, uint32_t ms);
+    void (*timer_cancel)(const SpiceCoreInterfaceInternal *iface, SpiceTimer *timer);
+    void (*timer_remove)(const SpiceCoreInterfaceInternal *iface, SpiceTimer *timer);
 
     SpiceWatch *(*watch_add)(const SpiceCoreInterfaceInternal *iface, int fd, int event_mask, SpiceWatchFunc func, void *opaque);
-    void (*watch_update_mask)(SpiceWatch *watch, int event_mask);
-    void (*watch_remove)(SpiceWatch *watch);
+    void (*watch_update_mask)(const SpiceCoreInterfaceInternal *iface, SpiceWatch *watch, int event_mask);
+    void (*watch_remove)(const SpiceCoreInterfaceInternal *iface, SpiceWatch *watch);
 
-    void (*channel_event)(int event, SpiceChannelEventInfo *info);
+    void (*channel_event)(const SpiceCoreInterfaceInternal *iface, int event, SpiceChannelEventInfo *info);
 
-    GMainContext *main_context;
+    union {
+        GMainContext *main_context;
+        SpiceCoreInterface *public_interface;
+    };
 };
 
 extern const SpiceCoreInterfaceInternal event_loop_core;
diff --git a/server/reds-private.h b/server/reds-private.h
index 0408f25..ddd2e0f 100644
--- a/server/reds-private.h
+++ b/server/reds-private.h
@@ -153,7 +153,7 @@ struct RedsState {
     SpiceCharDeviceInstance *vdagent;
     SpiceMigrateInstance *migration_interface;
 
-    SpiceCoreInterfaceInternal *core;
+    SpiceCoreInterfaceInternal core;
     GList *qxl_instances;
     MainDispatcher *main_dispatcher;
 };
diff --git a/server/reds.c b/server/reds.c
index 56138e1..e684451 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -76,52 +76,49 @@
 static void reds_client_monitors_config(RedsState *reds, VDAgentMonitorsConfig *monitors_config);
 static gboolean reds_use_client_monitors_config(RedsState *reds);
 
-static SpiceCoreInterface *core_public = NULL;
-
 static SpiceTimer *adapter_timer_add(const SpiceCoreInterfaceInternal *iface, SpiceTimerFunc func, void *opaque)
 {
-    return core_public->timer_add(func, opaque);
+    return iface->public_interface->timer_add(func, opaque);
 }
 
-static void adapter_timer_start(SpiceTimer *timer, uint32_t ms)
+static void adapter_timer_start(const SpiceCoreInterfaceInternal *iface, SpiceTimer *timer, uint32_t ms)
 {
-    core_public->timer_start(timer, ms);
+    iface->public_interface->timer_start(timer, ms);
 }
 
-static void adapter_timer_cancel(SpiceTimer *timer)
+static void adapter_timer_cancel(const SpiceCoreInterfaceInternal *iface, SpiceTimer *timer)
 {
-    core_public->timer_cancel(timer);
+    iface->public_interface->timer_cancel(timer);
 }
 
-static void adapter_timer_remove(SpiceTimer *timer)
+static void adapter_timer_remove(const SpiceCoreInterfaceInternal *iface, SpiceTimer *timer)
 {
-    core_public->timer_remove(timer);
+    iface->public_interface->timer_remove(timer);
 }
 
 static SpiceWatch *adapter_watch_add(const SpiceCoreInterfaceInternal *iface,
                                      int fd, int event_mask, SpiceWatchFunc func, void *opaque)
 {
-    return core_public->watch_add(fd, event_mask, func, opaque);
+    return iface->public_interface->watch_add(fd, event_mask, func, opaque);
 }
 
-static void adapter_watch_update_mask(SpiceWatch *watch, int event_mask)
+static void adapter_watch_update_mask(const SpiceCoreInterfaceInternal *iface, SpiceWatch *watch, int event_mask)
 {
-    core_public->watch_update_mask(watch, event_mask);
+    iface->public_interface->watch_update_mask(watch, event_mask);
 }
 
-static void adapter_watch_remove(SpiceWatch *watch)
+static void adapter_watch_remove(const SpiceCoreInterfaceInternal *iface, SpiceWatch *watch)
 {
-    core_public->watch_remove(watch);
+    iface->public_interface->watch_remove(watch);
 }
 
-static void adapter_channel_event(int event, SpiceChannelEventInfo *info)
+static void adapter_channel_event(const SpiceCoreInterfaceInternal *iface, int event, SpiceChannelEventInfo *info)
 {
-    if (core_public->base.minor_version >= 3 && core_public->channel_event != NULL)
-        core_public->channel_event(event, info);
+    if (iface->public_interface->base.minor_version >= 3 && iface->public_interface->channel_event != NULL)
+        iface->public_interface->channel_event(event, info);
 }
 
-
-static SpiceCoreInterfaceInternal core_interface_adapter = {
+static const SpiceCoreInterfaceInternal core_interface_adapter = {
     .timer_add = adapter_timer_add,
     .timer_start = adapter_timer_start,
     .timer_cancel = adapter_timer_cancel,
@@ -322,7 +319,7 @@ static ChannelSecurityOptions *reds_find_channel_security(RedsState *reds, int i
 
 void reds_handle_channel_event(RedsState *reds, int event, SpiceChannelEventInfo *info)
 {
-    reds->core->channel_event(event, info);
+    reds->core.channel_event(&reds->core, event, info);
 
     if (event == SPICE_CHANNEL_EVENT_DISCONNECTED) {
         free(info);
@@ -514,7 +511,7 @@ static void reds_mig_cleanup(RedsState *reds)
         reds->mig_inprogress = FALSE;
         reds->mig_wait_connect = FALSE;
         reds->mig_wait_disconnect = FALSE;
-        reds->core->timer_cancel(reds->mig_timer);
+        reds_core_timer_cancel(reds, reds->mig_timer);
         reds_mig_cleanup_wait_disconnect(reds);
     }
 }
@@ -2972,7 +2969,7 @@ static void reds_mig_started(RedsState *reds)
 
     reds->mig_inprogress = TRUE;
     reds->mig_wait_connect = TRUE;
-    reds->core->timer_start(reds->mig_timer, MIGRATE_TIMEOUT);
+    reds_core_timer_start(reds, reds->mig_timer, MIGRATE_TIMEOUT);
 }
 
 static void reds_mig_fill_wait_disconnect(RedsState *reds)
@@ -2988,7 +2985,7 @@ static void reds_mig_fill_wait_disconnect(RedsState *reds)
         reds->mig_wait_disconnect_clients = g_list_append(reds->mig_wait_disconnect_clients, client);
     }
     reds->mig_wait_disconnect = TRUE;
-    reds->core->timer_start(reds->mig_timer, MIGRATE_TIMEOUT);
+    reds_core_timer_start(reds, reds->mig_timer, MIGRATE_TIMEOUT);
 }
 
 static void reds_mig_cleanup_wait_disconnect(RedsState *reds)
@@ -3415,21 +3412,21 @@ static int do_spice_init(RedsState *reds, SpiceCoreInterface *core_interface)
         spice_warning("bad core interface version");
         goto err;
     }
-    core_public = core_interface;
-    reds->core = &core_interface_adapter;
+    reds->core = core_interface_adapter;
+    reds->core.public_interface = core_interface;
     reds->listen_socket = -1;
     reds->secure_listen_socket = -1;
     reds->agent_dev = red_char_device_vdi_port_new(reds);
     ring_init(&reds->clients);
     reds->num_clients = 0;
-    reds->main_dispatcher = main_dispatcher_new(reds, reds->core);
+    reds->main_dispatcher = main_dispatcher_new(reds, &reds->core);
     ring_init(&reds->channels);
     ring_init(&reds->mig_target_clients);
     reds->char_devices = NULL;
     reds->mig_wait_disconnect_clients = NULL;
     reds->vm_running = TRUE; /* for backward compatibility */
 
-    if (!(reds->mig_timer = reds->core->timer_add(reds->core, migrate_timeout, reds))) {
+    if (!(reds->mig_timer = reds->core.timer_add(&reds->core, migrate_timeout, reds))) {
         spice_error("migration timer create failed");
     }
 
@@ -4213,7 +4210,7 @@ spice_wan_compression_t reds_get_zlib_glz_state(const RedsState *reds)
 
 SpiceCoreInterfaceInternal* reds_get_core_interface(RedsState *reds)
 {
-    return reds->core;
+    return &reds->core;
 }
 
 SpiceWatch *reds_core_watch_add(RedsState *reds,
@@ -4222,10 +4219,9 @@ SpiceWatch *reds_core_watch_add(RedsState *reds,
                                 void *opaque)
 {
    g_return_val_if_fail(reds != NULL, NULL);
-   g_return_val_if_fail(reds->core != NULL, NULL);
-   g_return_val_if_fail(reds->core->watch_add != NULL, NULL);
+   g_return_val_if_fail(reds->core.watch_add != NULL, NULL);
 
-   return reds->core->watch_add(reds->core, fd, event_mask, func, opaque);
+   return reds->core.watch_add(&reds->core, fd, event_mask, func, opaque);
 }
 
 void reds_core_watch_update_mask(RedsState *reds,
@@ -4233,19 +4229,17 @@ void reds_core_watch_update_mask(RedsState *reds,
                                  int event_mask)
 {
    g_return_if_fail(reds != NULL);
-   g_return_if_fail(reds->core != NULL);
-   g_return_if_fail(reds->core->watch_update_mask != NULL);
+   g_return_if_fail(reds->core.watch_update_mask != NULL);
 
-   reds->core->watch_update_mask(watch, event_mask);
+   reds->core.watch_update_mask(&reds->core, watch, event_mask);
 }
 
 void reds_core_watch_remove(RedsState *reds, SpiceWatch *watch)
 {
    g_return_if_fail(reds != NULL);
-   g_return_if_fail(reds->core != NULL);
-   g_return_if_fail(reds->core->watch_remove != NULL);
+   g_return_if_fail(reds->core.watch_remove != NULL);
 
-   reds->core->watch_remove(watch);
+   reds->core.watch_remove(&reds->core, watch);
 }
 
 SpiceTimer *reds_core_timer_add(RedsState *reds,
@@ -4253,10 +4247,9 @@ SpiceTimer *reds_core_timer_add(RedsState *reds,
                                 void *opaque)
 {
    g_return_val_if_fail(reds != NULL, NULL);
-   g_return_val_if_fail(reds->core != NULL, NULL);
-   g_return_val_if_fail(reds->core->timer_add != NULL, NULL);
+   g_return_val_if_fail(reds->core.timer_add != NULL, NULL);
 
-   return reds->core->timer_add(reds->core, func, opaque);
+   return reds->core.timer_add(&reds->core, func, opaque);
 
 }
 
@@ -4265,30 +4258,27 @@ void reds_core_timer_start(RedsState *reds,
                            uint32_t ms)
 {
    g_return_if_fail(reds != NULL);
-   g_return_if_fail(reds->core != NULL);
-   g_return_if_fail(reds->core->timer_start != NULL);
+   g_return_if_fail(reds->core.timer_start != NULL);
 
-   return reds->core->timer_start(timer, ms);
+   return reds->core.timer_start(&reds->core, timer, ms);
 }
 
 void reds_core_timer_cancel(RedsState *reds,
                             SpiceTimer *timer)
 {
    g_return_if_fail(reds != NULL);
-   g_return_if_fail(reds->core != NULL);
-   g_return_if_fail(reds->core->timer_cancel != NULL);
+   g_return_if_fail(reds->core.timer_cancel != NULL);
 
-   return reds->core->timer_cancel(timer);
+   return reds->core.timer_cancel(&reds->core, timer);
 }
 
 void reds_core_timer_remove(RedsState *reds,
                             SpiceTimer *timer)
 {
    g_return_if_fail(reds != NULL);
-   g_return_if_fail(reds->core != NULL);
-   g_return_if_fail(reds->core->timer_remove != NULL);
+   g_return_if_fail(reds->core.timer_remove != NULL);
 
-   return reds->core->timer_remove(timer);
+   return reds->core.timer_remove(&reds->core, timer);
 }
 
 void reds_update_client_mouse_allowed(RedsState *reds)
diff --git a/server/tests/basic_event_loop.c b/server/tests/basic_event_loop.c
index 4820387..2029424 100644
--- a/server/tests/basic_event_loop.c
+++ b/server/tests/basic_event_loop.c
@@ -73,18 +73,49 @@ static SpiceTimer* base_timer_add(SpiceTimerFunc func, void *opaque)
     return base_core_interface.timer_add(&base_core_interface, func, opaque);
 }
 
+static void base_timer_start(SpiceTimer *timer, uint32_t ms)
+{
+    base_core_interface.timer_start(&base_core_interface, timer, ms);
+}
+
+static void base_timer_cancel(SpiceTimer *timer)
+{
+    base_core_interface.timer_cancel(&base_core_interface, timer);
+}
+
+static void base_timer_remove(SpiceTimer *timer)
+{
+    base_core_interface.timer_remove(&base_core_interface, timer);
+}
+
 static SpiceWatch *base_watch_add(int fd, int event_mask, SpiceWatchFunc func, void *opaque)
 {
     return base_core_interface.watch_add(&base_core_interface, fd, event_mask, func, opaque);
 }
 
+static void base_watch_update_mask(SpiceWatch *watch, int event_mask)
+{
+    base_core_interface.watch_update_mask(&base_core_interface, watch, event_mask);
+}
+
+static void base_watch_remove(SpiceWatch *watch)
+{
+    base_core_interface.watch_remove(&base_core_interface, watch);
+}
+
 static SpiceCoreInterface core = {
     .base = {
         .major_version = SPICE_INTERFACE_CORE_MAJOR,
         .minor_version = SPICE_INTERFACE_CORE_MINOR,
     },
     .timer_add = base_timer_add,
+    .timer_start = base_timer_start,
+    .timer_cancel = base_timer_cancel,
+    .timer_remove = base_timer_remove,
     .watch_add = base_watch_add,
+    .watch_update_mask = base_watch_update_mask,
+    .watch_remove = base_watch_remove,
+    .channel_event = event_loop_channel_event,
 };
 
 SpiceCoreInterface *basic_event_loop_init(void)
@@ -93,12 +124,6 @@ SpiceCoreInterface *basic_event_loop_init(void)
     spice_assert(main_context == NULL);
     main_context = g_main_context_new();
     base_core_interface = event_loop_core;
-    core.timer_start = base_core_interface.timer_start;
-    core.timer_cancel = base_core_interface.timer_cancel;
-    core.timer_remove = base_core_interface.timer_remove;
-    core.watch_update_mask = base_core_interface.watch_update_mask;
-    core.watch_remove = base_core_interface.watch_remove;
-    base_core_interface.channel_event = core.channel_event = event_loop_channel_event;
     base_core_interface.main_context = main_context;
 
     return &core;
-- 
2.7.4

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]