diff options
author | Sai Pavan Boddu <sai.pavan.boddu@xilinx.com> | 2020-04-19 15:21:40 +0530 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2020-06-10 12:10:45 -0400 |
commit | 4d1d4602488fd5f3c0f0601feac4289b474add37 (patch) | |
tree | 2cd48d135941236c4867747b0b845eea3048ee51 /chardev/char-socket.c | |
parent | c82d9d43ed5d1a7021890d788193fdbeae1011c8 (diff) |
chardev/char-socket: Properly make qio connections non blocking
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>
Message-Id: <1587289900-29485-1-git-send-email-sai.pavan.boddu@xilinx.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'chardev/char-socket.c')
-rw-r--r-- | chardev/char-socket.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/chardev/char-socket.c b/chardev/char-socket.c index db253d4024..dd3d3ed8d6 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -550,7 +550,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); |