[Spice-devel] [PATCH 16/17] Remove use of global 'reds' from AgentMsgFilter

Frediano Ziglio fziglio at redhat.com
Thu Feb 11 19:24:15 UTC 2016


From: Jonathon Jongsma <jjongsma at redhat.com>

---
 server/agent-msg-filter.c |  7 +++++--
 server/agent-msg-filter.h | 11 +++++++----
 server/reds.c             | 14 ++++++++++----
 3 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/server/agent-msg-filter.c b/server/agent-msg-filter.c
index 069822b..14d5100 100644
--- a/server/agent-msg-filter.c
+++ b/server/agent-msg-filter.c
@@ -28,11 +28,14 @@
 #include "red-dispatcher.h"
 
 void agent_msg_filter_init(struct AgentMsgFilter *filter,
-                           int copy_paste, int file_xfer, int discard_all)
+                           gboolean copy_paste, gboolean file_xfer,
+                           gboolean use_client_monitors_config,
+                           int discard_all)
 {
     memset(filter, 0, sizeof(*filter));
     filter->copy_paste_enabled = copy_paste;
     filter->file_xfer_enabled = file_xfer;
+    filter->use_client_monitors_config = use_client_monitors_config;
     filter->discard_all = discard_all;
 }
 
@@ -93,7 +96,7 @@ data_to_read:
             }
             break;
         case VD_AGENT_MONITORS_CONFIG:
-            if (reds_use_client_monitors_config(reds)) {
+            if (filter->use_client_monitors_config) {
                 filter->result = AGENT_MSG_FILTER_MONITORS_CONFIG;
             } else {
                 filter->result = AGENT_MSG_FILTER_OK;
diff --git a/server/agent-msg-filter.h b/server/agent-msg-filter.h
index 92aabce..c04face 100644
--- a/server/agent-msg-filter.h
+++ b/server/agent-msg-filter.h
@@ -35,13 +35,16 @@ enum {
 typedef struct AgentMsgFilter {
     int msg_data_to_read;
     int result;
-    int copy_paste_enabled;
-    int file_xfer_enabled;
-    int discard_all;
+    gboolean copy_paste_enabled;
+    gboolean file_xfer_enabled;
+    gboolean use_client_monitors_config;
+    gboolean discard_all;
 } AgentMsgFilter;
 
 void agent_msg_filter_init(struct AgentMsgFilter *filter,
-                           int copy_paste, int file_xfer, int discard_all);
+                           gboolean copy_paste, gboolean file_xfer,
+                           gboolean use_client_monitors_config,
+                           gboolean discard_all);
 int agent_msg_filter_process_data(struct AgentMsgFilter *filter,
                                   uint8_t *data, uint32_t len);
 
diff --git a/server/reds.c b/server/reds.c
index 5931791..0349330 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -407,7 +407,8 @@ static void reds_reset_vdp(RedsState *reds)
     }
     /* Reset read filter to start with clean state when the agent reconnects */
     agent_msg_filter_init(&state->read_filter, reds->agent_copypaste,
-                          reds->agent_file_xfer, TRUE);
+                          reds->agent_file_xfer,
+                          reds_use_client_monitors_config(reds), TRUE);
     /* Throw away pending chunks from the current (if any) and future
      * messages written by the client.
      * TODO: client should clear its agent messages queue when the agent
@@ -521,7 +522,8 @@ void reds_client_disconnect(RedsState *reds, RedClient *client)
 
         /* Reset write filter to start with clean state on client reconnect */
         agent_msg_filter_init(&reds->agent_state.write_filter, reds->agent_copypaste,
-                              reds->agent_file_xfer, TRUE);
+                              reds->agent_file_xfer,
+                              reds_use_client_monitors_config(reds), TRUE);
 
         /* Throw away pending chunks from the current (if any) and future
          *  messages read from the agent */
@@ -3210,6 +3212,8 @@ SPICE_GNUC_VISIBLE int spice_server_add_interface(SpiceServer *s,
         qxl->st->qif = SPICE_CONTAINEROF(interface, QXLInterface, base);
         red_dispatcher_init(reds, qxl, calc_compression_level(reds));
         reds->dispatchers = g_list_prepend(reds->dispatchers, qxl->st->dispatcher);
+        reds->agent_state.write_filter.use_client_monitors_config = reds_use_client_monitors_config(reds);
+        reds->agent_state.read_filter.use_client_monitors_config = reds_use_client_monitors_config(reds);
 
     } else if (strcmp(interface->type, SPICE_INTERFACE_TABLET) == 0) {
         SpiceTabletInstance *tablet = SPICE_CONTAINEROF(sin, SpiceTabletInstance, base);
@@ -3308,9 +3312,11 @@ static void reds_init_vd_agent_resources(RedsState *reds)
 
     ring_init(&state->read_bufs);
     agent_msg_filter_init(&state->write_filter, reds->agent_copypaste,
-                          reds->agent_file_xfer, TRUE);
+                          reds->agent_file_xfer,
+                          reds_use_client_monitors_config(reds), TRUE);
     agent_msg_filter_init(&state->read_filter, reds->agent_copypaste,
-                          reds->agent_file_xfer, TRUE);
+                          reds->agent_file_xfer,
+                          reds_use_client_monitors_config(reds), TRUE);
 
     state->read_state = VDI_PORT_READ_STATE_READ_HEADER;
     state->receive_pos = (uint8_t *)&state->vdi_chunk_header;
-- 
2.5.0



More information about the Spice-devel mailing list