[Spice-devel] [PATCH 1/2] agent_msg_filter_process_data(): always return _MONITORS_CONFIG

Jonathon Jongsma jjongsma at redhat.com
Wed Apr 1 08:41:51 PDT 2015


Instead of having a check inside of the agent message filter to see
whether the RedDispatcher should use the client monitors config, move
this check out to the caller and always return
AGENT_MSG_FILTER_MONITORS_CONFIG for monitor configuration messages.
This simplifies the responsibilities of the message filter (it no longer
has to obtain a reference to the dispatcher to determine how to filter
messages) and also prepares the way for the caller to determine whether
a particular message was a MonitorsConfig message (which will be useful
in a future commit)
---
 server/agent-msg-filter.c |  6 +-----
 server/reds.c             | 12 ++++++++++--
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/server/agent-msg-filter.c b/server/agent-msg-filter.c
index 567e03d..5673aa4 100644
--- a/server/agent-msg-filter.c
+++ b/server/agent-msg-filter.c
@@ -92,11 +92,7 @@ data_to_read:
             }
             break;
         case VD_AGENT_MONITORS_CONFIG:
-            if (red_dispatcher_use_client_monitors_config()) {
-                filter->result = AGENT_MSG_FILTER_MONITORS_CONFIG;
-            } else {
-                filter->result = AGENT_MSG_FILTER_OK;
-            }
+            filter->result = AGENT_MSG_FILTER_MONITORS_CONFIG;
             break;
         default:
             filter->result = AGENT_MSG_FILTER_OK;
diff --git a/server/reds.c b/server/reds.c
index cc4d789..4e36961 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -621,6 +621,10 @@ static int vdi_port_read_buf_process(int port, VDIReadBuf *buf)
             return TRUE;
         case AGENT_MSG_FILTER_DISCARD:
             return FALSE;
+        case AGENT_MSG_FILTER_MONITORS_CONFIG:
+            if (red_dispatcher_use_client_monitors_config())
+                return FALSE;
+            return TRUE;
         case AGENT_MSG_FILTER_PROTO_ERROR:
             reds_agent_remove();
             return FALSE;
@@ -1029,8 +1033,12 @@ void reds_on_main_agent_data(MainChannelClient *mcc, void *message, size_t size)
     case AGENT_MSG_FILTER_DISCARD:
         return;
     case AGENT_MSG_FILTER_MONITORS_CONFIG:
-        reds_on_main_agent_monitors_config(mcc, message, size);
-        return;
+        if (red_dispatcher_use_client_monitors_config()) {
+            reds_on_main_agent_monitors_config(mcc, message, size);
+            return;
+        }
+        /* else forward to vdagent */
+        break;
     case AGENT_MSG_FILTER_PROTO_ERROR:
         red_channel_client_shutdown(main_channel_client_get_base(mcc));
         return;
-- 
2.1.0



More information about the Spice-devel mailing list