aboutsummaryrefslogtreecommitdiff
path: root/chardev/char-socket.c
diff options
context:
space:
mode:
Diffstat (limited to 'chardev/char-socket.c')
-rw-r--r--chardev/char-socket.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/chardev/char-socket.c b/chardev/char-socket.c
index 18e762643b..afebeec5c3 100644
--- a/chardev/char-socket.c
+++ b/chardev/char-socket.c
@@ -551,7 +551,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);