File virtio-port-handle_fds-make-read-and-write-code-cons.patch of Package spice-vdagent.17026

From 8c59da79cde103f391d1b467819150a5f57e4e4a Mon Sep 17 00:00:00 2001
From: Uri Lublin <uril@redhat.com>
Date: Thu, 29 Aug 2019 19:35:24 +0300
Subject: [PATCH 03/20] virtio-port: handle_fds: make read and write code
 consistent

Git-commit: f807e98bb6474949e74e1890fd483d7ef4011a6c
References: bsc#1173749

A comment and curly brackets for style were added.

Signed-off-by: Uri Lublin <uril@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
Signed-off-by: Bruce Rogers <brogers@suse.com>
---
 src/vdagentd/virtio-port.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/vdagentd/virtio-port.c b/src/vdagentd/virtio-port.c
index 3ae7f22..06f3a32 100644
--- a/src/vdagentd/virtio-port.c
+++ b/src/vdagentd/virtio-port.c
@@ -166,14 +166,14 @@ int vdagent_virtio_port_fill_fds(struct vdagent_virtio_port *vport,
 void vdagent_virtio_port_handle_fds(struct vdagent_virtio_port **vportp,
         fd_set *readfds, fd_set *writefds)
 {
-    if (!*vportp)
-        return;
-
-    if (FD_ISSET((*vportp)->fd, readfds))
+    if (*vportp && FD_ISSET((*vportp)->fd, readfds)) {
         vdagent_virtio_port_do_read(vportp);
+    }
 
-    if (*vportp && FD_ISSET((*vportp)->fd, writefds))
+    /* *vportp may have been destroyed in do_read */
+    if (*vportp && FD_ISSET((*vportp)->fd, writefds)) {
         vdagent_virtio_port_do_write(vportp);
+    }
 }
 
 static struct vdagent_virtio_port_buf* vdagent_virtio_port_get_last_wbuf(
-- 
2.29.0

openSUSE Build Service is sponsored by