[PATCH 04/15] Change vdi_port_read_buf_unref() to take RedsState arg

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

 



From: Jonathon Jongsma <jjongsma@xxxxxxxxxx>

---
 server/reds.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/server/reds.c b/server/reds.c
index 928cb83..4e0caba 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -214,7 +214,7 @@ static void reds_send_mm_time(void);
 
 static VDIReadBuf *vdi_port_read_buf_get(RedsState *reds);
 static VDIReadBuf *vdi_port_read_buf_ref(VDIReadBuf *buf);
-static void vdi_port_read_buf_unref(VDIReadBuf *buf);
+static void vdi_port_read_buf_unref(RedsState *reds, VDIReadBuf *buf);
 
 static ChannelSecurityOptions *channels_security = NULL;
 static int default_channel_security =
@@ -440,7 +440,7 @@ static void reds_reset_vdp(RedsState *reds)
     state->receive_len = sizeof(state->vdi_chunk_header);
     state->message_receive_len = 0;
     if (state->current_read_buf) {
-        vdi_port_read_buf_unref(state->current_read_buf);
+        vdi_port_read_buf_unref(reds, state->current_read_buf);
         state->current_read_buf = NULL;
     }
     /* Reset read filter to start with clean state when the agent reconnects */
@@ -658,7 +658,7 @@ static void vdi_port_read_buf_release(uint8_t *data, void *opaque)
 {
     VDIReadBuf *buf = (VDIReadBuf *)opaque;
 
-    vdi_port_read_buf_unref(buf);
+    vdi_port_read_buf_unref(reds, buf);
 }
 
 /* returns TRUE if the buffer can be forwarded */
@@ -713,7 +713,9 @@ static VDIReadBuf* vdi_port_read_buf_ref(VDIReadBuf *buf)
     return buf;
 }
 
-static void vdi_port_read_buf_unref(VDIReadBuf *buf)
+/* FIXME: refactor so that unreffing the VDIReadBuf doesn't require accessing
+ * RedsState? */
+static void vdi_port_read_buf_unref(RedsState *reds, VDIReadBuf *buf)
 {
     if (!--buf->refs) {
         ring_add(&reds->agent_state.read_bufs, &buf->link);
@@ -790,7 +792,7 @@ static SpiceCharDeviceMsgToClient *vdi_port_read_one_msg_from_device(SpiceCharDe
             if (vdi_port_read_buf_process(reds, state->vdi_chunk_header.port, dispatch_buf)) {
                 return dispatch_buf;
             } else {
-                vdi_port_read_buf_unref(dispatch_buf);
+                vdi_port_read_buf_unref(reds, dispatch_buf);
             }
         } /* END switch */
     } /* END while */
@@ -806,7 +808,8 @@ static SpiceCharDeviceMsgToClient *vdi_port_ref_msg_to_client(SpiceCharDeviceMsg
 static void vdi_port_unref_msg_to_client(SpiceCharDeviceMsgToClient *msg,
                                   void *opaque)
 {
-    vdi_port_read_buf_unref(msg);
+    RedsState *reds = opaque;
+    vdi_port_read_buf_unref(reds, msg);
 }
 
 /* after calling this, we unref the message, and the ref is in the instance side */
@@ -1163,7 +1166,7 @@ void reds_on_main_channel_migrate(MainChannelClient *mcc)
                                                 vdi_port_read_buf_release,
                                                 read_buf);
         } else {
-            vdi_port_read_buf_unref(read_buf);
+            vdi_port_read_buf_unref(reds, read_buf);
         }
 
         spice_assert(agent_state->receive_len);
-- 
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]