Skip to contentSkip to conversation

char: ensure all clients are in non-blocking mode

PATCH In review Daniel P. Berrange 2 participants 2 messages Mar 18, 2016 – Mar 19, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 char: ensure all clients are in non-blocking mode

Only some callers of tcp_chr_new_client are putting the socket client into non-blocking mode. Move the call to qio_channel_set_blocking() into the tcp_chr_new_client method to guarantee that all code paths set non-blocking mode

---
 qemu-char.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
qemu-char.c +2 -1
index bfcf80d..144764e 100644
@@ -3071,6 +3071,8 @@ static int tcp_chr_new_client(CharDriverState *chr, QIOChannelSocket *sioc)
     s->sioc = sioc;
     object_ref(OBJECT(sioc));
 
+    qio_channel_set_blocking(s->ioc, false, NULL);
+
     if (s->do_nodelay) {
         qio_channel_set_delay(s->ioc, false);
     }
@@ -3102,7 +3104,6 @@ static int tcp_chr_add_client(CharDriverState *chr, int fd)
     if (!sioc) {
         return -1;
     }
-    qio_channel_set_blocking(QIO_CHANNEL(sioc), false, NULL);
     ret = tcp_chr_new_client(chr, sioc);
     object_unref(OBJECT(sioc));
     return ret;
Signature · 1 line
2.5.0
#1 lore raw
Quoted 28 lines · Daniel P. Berrange

Only some callers of tcp_chr_new_client are putting the socket client into non-blocking mode. Move the call to qio_channel_set_blocking() into the tcp_chr_new_client method to guarantee that all code paths set non-blocking mode

---
 qemu-char.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
qemu-char.c +2 -0
index bfcf80d..144764e 100644
@@ -3071,6 +3071,8 @@ static int tcp_chr_new_client(CharDriverState *chr, QIOChannelSocket *sioc)
     s->sioc = sioc;
     object_ref(OBJECT(sioc));
 
+    qio_channel_set_blocking(s->ioc, false, NULL);
+
     if (s->do_nodelay) {
         qio_channel_set_delay(s->ioc, false);
     }

qemu-char.c static int tcp_chr_add_client(CharDriverState *chr, int fd) · line 3109

Quoted 7 lines
qemu-char.c +0 -1
@@ -3102,7 +3104,6 @@ static int tcp_chr_add_client(CharDriverState *chr, int fd)
     if (!sioc) {
         return -1;
     }
-    qio_channel_set_blocking(QIO_CHANNEL(sioc), false, NULL);
     ret = tcp_chr_new_client(chr, sioc);
     object_unref(OBJECT(sioc));
     return ret;

Thanks, queued.

Paolo