[PATCH 4/4] channel: use iface parameter to distinguish interface context

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

 



---
 server/red-worker.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/server/red-worker.c b/server/red-worker.c
index b0b7df1..0347404 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -71,6 +71,7 @@ struct RedWorker {
     QXLInstance *qxl;
     RedDispatcher *red_dispatcher;
     int running;
+    SpiceCoreInterfaceInternal core;
     struct pollfd poll_fds[MAX_EVENT_SOURCES];
     struct SpiceWatch watches[MAX_EVENT_SOURCES];
     unsigned int event_timeout;
@@ -534,16 +535,12 @@ static void worker_watch_update_mask(SpiceWatch *watch, int event_mask)
 static SpiceWatch *worker_watch_add(const SpiceCoreInterfaceInternal *iface,
                                     int fd, int event_mask, SpiceWatchFunc func, void *opaque)
 {
+    RedWorker *worker = SPICE_CONTAINEROF(iface, RedWorker, core);
     /* Since we are a channel core implementation, we always get called from
        red_channel_client_create(), so opaque always is our rcc */
     RedChannelClient *rcc = opaque;
-    struct RedWorker *worker;
     int i;
 
-    /* Since we are called from red_channel_client_create()
-       CommonChannelClient->worker has not been set yet! */
-    worker = SPICE_CONTAINEROF(rcc->channel, CommonChannel, base)->worker;
-
     /* Search for a free slot in our poll_fds & watches arrays */
     for (i = 0; i < MAX_EVENT_SOURCES; i++) {
         if (worker->poll_fds[i].fd == -1) {
@@ -581,7 +578,7 @@ static void worker_watch_remove(SpiceWatch *watch)
     memset(watch, 0, sizeof(SpiceWatch));
 }
 
-SpiceCoreInterfaceInternal worker_core = {
+static const SpiceCoreInterfaceInternal worker_core_initializer = {
     .timer_add = spice_timer_queue_add,
     .timer_start = spice_timer_set,
     .timer_cancel = spice_timer_cancel,
@@ -641,7 +638,7 @@ CommonChannel *red_worker_new_channel(RedWorker *worker, int size,
     channel_cbs->alloc_recv_buf = common_alloc_recv_buf;
     channel_cbs->release_recv_buf = common_release_recv_buf;
 
-    channel = red_channel_create_parser(size, &worker_core,
+    channel = red_channel_create_parser(size, &worker->core,
                                         channel_type, worker->qxl->id,
                                         TRUE /* handle_acks */,
                                         spice_get_client_channel_parser(channel_type, NULL),
@@ -1546,6 +1543,7 @@ RedWorker* red_worker_new(QXLInstance *qxl, RedDispatcher *red_dispatcher)
     qxl->st->qif->get_init_info(qxl, &init_info);
 
     worker = spice_new0(RedWorker, 1);
+    worker->core = worker_core_initializer;
 
     record_filename = getenv("SPICE_WORKER_RECORD_FILENAME");
     if (record_filename) {
-- 
2.4.3

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://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]