[Spice-devel] [spice-server 1/3] Revert "fix regression due to callback called earlier"

Christophe Fergeau cfergeau at redhat.com
Fri Mar 18 15:29:37 UTC 2016


Passing Reds into agent-msg-filter.[ch] isn't the right thing to do from
a layering point of view.

This reverts commit a1e62fa5ae983b7b69cb437b2635ce84b2471383.
---
 server/agent-msg-filter.c |  5 +++--
 server/agent-msg-filter.h |  3 ++-
 server/reds.c             | 18 ++++++++++++------
 spice-common              |  2 +-
 4 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/server/agent-msg-filter.c b/server/agent-msg-filter.c
index a6aee9e..db8526e 100644
--- a/server/agent-msg-filter.c
+++ b/server/agent-msg-filter.c
@@ -29,16 +29,17 @@
 
 void agent_msg_filter_init(struct AgentMsgFilter *filter,
                            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;
 }
 
 int agent_msg_filter_process_data(struct AgentMsgFilter *filter,
-                                  RedsState *reds,
                                   uint8_t *data, uint32_t len)
 {
     struct VDAgentMessage msg_header;
@@ -95,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 a4fc4cf..c04face 100644
--- a/server/agent-msg-filter.h
+++ b/server/agent-msg-filter.h
@@ -37,14 +37,15 @@ typedef struct AgentMsgFilter {
     int result;
     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,
                            gboolean copy_paste, gboolean file_xfer,
+                           gboolean use_client_monitors_config,
                            gboolean discard_all);
 int agent_msg_filter_process_data(struct AgentMsgFilter *filter,
-                                  SpiceServer *reds,
                                   uint8_t *data, uint32_t len);
 
 #endif
diff --git a/server/reds.c b/server/reds.c
index b1e1139..7fd80a8 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 */
@@ -637,7 +639,7 @@ static int vdi_port_read_buf_process(RedsState *reds, VDIReadBuf *buf)
 
     switch (state->vdi_chunk_header.port) {
     case VDP_CLIENT_PORT: {
-        res = agent_msg_filter_process_data(&state->read_filter, reds,
+        res = agent_msg_filter_process_data(&state->read_filter,
                                             buf->data, buf->len);
         switch (res) {
         case AGENT_MSG_FILTER_OK:
@@ -1047,7 +1049,7 @@ void reds_on_main_agent_data(RedsState *reds, MainChannelClient *mcc, void *mess
     VDIChunkHeader *header;
     int res;
 
-    res = agent_msg_filter_process_data(&reds->agent_state.write_filter, reds,
+    res = agent_msg_filter_process_data(&reds->agent_state.write_filter,
                                         message, size);
     switch (res) {
     case AGENT_MSG_FILTER_OK:
@@ -3188,6 +3190,8 @@ SPICE_GNUC_VISIBLE int spice_server_add_interface(SpiceServer *s,
         red_qxl_init(reds, qxl);
         qxl_state = qxl->st;
         reds->qxl_states = g_list_prepend(reds->qxl_states, qxl_state);
+        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);
 
         /* this function has to be called after the qxl is on the list
          * as QXLInstance clients expect the qxl to be on the list when
@@ -3293,9 +3297,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;
diff --git a/spice-common b/spice-common
index 00db440..fd9ba72 160000
--- a/spice-common
+++ b/spice-common
@@ -1 +1 @@
-Subproject commit 00db44087807335e74c8f65ea3e6fde0b684e7db
+Subproject commit fd9ba72f1a154249b039ebac9a38fe76b175cb7d
-- 
2.5.0



More information about the Spice-devel mailing list