On 8/28/19 7:13 PM, Frediano Ziglio wrote:
"return early" before write too
Signed-off-by: Uri Lublin <uril@xxxxxxxxxx>
---
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);
}
They are equivalent (beside the comment which can be added on top of
the if).
I like the alternative version if it's really important.
OK, I'll send v2 with the alternative.
Style: always brackets.
Yeah, I left it as it was ; I'll fix that too.
Thanks,
Uri.
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel