[Spice-devel] [PATCH spice 3/3] server: avoid unneeded recursion in dispatch_vdi_port_data

Hans de Goede hdegoede at redhat.com
Thu Mar 24 09:39:48 PDT 2011


dispatch_vdi_port_data, was calling vdi_read_buf_release when no client
is connected to free the passed in buf. The only difference between
vdi_read_buf_release and directly adding the buffer back to the ring
with ring_add, is that vdi_read_buf_release calls read_from_vdi_port
after adding the buffer back. But dispatch_vdi_port_data only gets called
from read_from_vdi_port itself, thus this would lead to recursing into
read_from_vdi_port. read_from_vdi_port is protected against recursion and
will immediately return if called recursively. Thus calling
vdi_read_buf_release from dispatch_vdi_port_data is pointless, instead
simply putting the buffer back in the ring suffices.
---
 server/reds.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/server/reds.c b/server/reds.c
index b4c4396..288174e 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -833,7 +833,7 @@ static void dispatch_vdi_port_data(int port, VDIReadBuf *buf)
                                          vdi_read_buf_release, buf);
         } else {
             red_printf("throwing away, no client: %d", buf->len);
-            vdi_read_buf_release(buf->data, buf);
+            ring_add(&state->read_bufs, &buf->link);
         }
         break;
     }
-- 
1.7.3.2



More information about the Spice-devel mailing list