[Spice-devel] [spice-vdagent PATCH 2/2] virtio-port: handle_fds: make read and write code consistent
Uri Lublin
uril at redhat.com
Wed Aug 28 16:02:34 UTC 2019
"return early" before write too
Signed-off-by: Uri Lublin <uril at redhat.com>
---
Alternatively, change the read part such that:
if (*vportp && FD_ISSET((*vportp)->fd, readfds))
vdagent_virtio_port_do_read
if (*vportp && FD_ISSET((*vportp)->fd, writefds))
vdagent_virtio_port_do_write
---
src/vdagentd/virtio-port.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/vdagentd/virtio-port.c b/src/vdagentd/virtio-port.c
index 3ae7f22..af5bd58 100644
--- a/src/vdagentd/virtio-port.c
+++ b/src/vdagentd/virtio-port.c
@@ -172,7 +172,10 @@ void vdagent_virtio_port_handle_fds(struct vdagent_virtio_port **vportp,
if (FD_ISSET((*vportp)->fd, readfds))
vdagent_virtio_port_do_read(vportp);
- if (*vportp && FD_ISSET((*vportp)->fd, writefds))
+ if (!*vportp) /* may have been destroyed in do_read */
+ return;
+
+ if (FD_ISSET((*vportp)->fd, writefds))
vdagent_virtio_port_do_write(vportp);
}
--
2.21.0
More information about the Spice-devel
mailing list