All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] chardev/char-socket: Properly make qio connections non blocking
@ 2020-04-19  9:51 Sai Pavan Boddu
  2020-04-20  9:26 ` Daniel P. Berrangé
  0 siblings, 1 reply; 3+ messages in thread
From: Sai Pavan Boddu @ 2020-04-19  9:51 UTC (permalink / raw)
  To: Marc-André Lureau, Daniel P . Berrangé, Eric Blake
  Cc: Paolo Bonzini, edgari, qemu-devel

In tcp_chr_sync_read function, there is a possibility of socket
disconnection during blocking read, then tcp_chr_hup function would clean up
the qio channel pointers(i.e ioc, sioc).

Signed-off-by: Sai Pavan Boddu <sai.pavan.boddu@xilinx.com>
---
Changes for V2:
	Place the guard around 'qio_channel_set_blocking' call to check connection status
	This fix is simpler than v1 and explains better about the issue.

 chardev/char-socket.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/chardev/char-socket.c b/chardev/char-socket.c
index 185fe38..e56b2f0 100644
--- a/chardev/char-socket.c
+++ b/chardev/char-socket.c
@@ -549,7 +549,9 @@ static int tcp_chr_sync_read(Chardev *chr, const uint8_t *buf, int len)
 
     qio_channel_set_blocking(s->ioc, true, NULL);
     size = tcp_chr_recv(chr, (void *) buf, len);
-    qio_channel_set_blocking(s->ioc, false, NULL);
+    if (s->state != TCP_CHARDEV_STATE_DISCONNECTED) {
+        qio_channel_set_blocking(s->ioc, false, NULL);
+    }
     if (size == 0) {
         /* connection closed */
         tcp_chr_disconnect(chr);
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-04-25 10:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-19  9:51 [PATCH v2] chardev/char-socket: Properly make qio connections non blocking Sai Pavan Boddu
2020-04-20  9:26 ` Daniel P. Berrangé
2020-04-25 10:46   ` Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.