Skip to contentSkip to conversation

char: fix handling of QIO_CHANNEL_ERR_BLOCK

PATCH Applied Daniel P. Berrange 2 participants 2 messages Feb 12, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 char: fix handling of QIO_CHANNEL_ERR_BLOCK

If io_channel_send_full gets QIO_CHANNEL_ERR_BLOCK it and has already sent some of the data, it should return that amount of data, not EAGAIN, as that would cause the caller to re-try already sent data.

Unfortunately due to a previous rebase conflict resolution error, the code for dealing with this was in the wrong part of the conditional, and so mistakenly ran on other I/O errors.

This be seen running

qemu-system-x86_64 -monitor stdio

and entering 'info mtree', when running on a slow console (eg a slow remote ssh session). The monitor would get into an indefinite loop writing the same data until it managed to send it all without getting EAGAIN.

---
 qemu-char.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
qemu-char.c +3 -3
index 1b7d5da..c2e24a5 100644
@@ -896,13 +896,13 @@ static int io_channel_send_full(QIOChannel *ioc,
             ioc, &iov, 1,
             fds, nfds, NULL);
         if (ret == QIO_CHANNEL_ERR_BLOCK) {
-            errno = EAGAIN;
-            return -1;
-        } else if (ret < 0) {
             if (offset) {
                 return offset;
             }
 
+            errno = EAGAIN;
+            return -1;
+        } else if (ret < 0) {
             errno = EINVAL;
             return -1;
         }
Signature · 1 line
2.5.0
#1 lore raw
Quoted 37 lines · Daniel P. Berrange

If io_channel_send_full gets QIO_CHANNEL_ERR_BLOCK it and has already sent some of the data, it should return that amount of data, not EAGAIN, as that would cause the caller to re-try already sent data.

Unfortunately due to a previous rebase conflict resolution error, the code for dealing with this was in the wrong part of the conditional, and so mistakenly ran on other I/O errors.

This be seen running

qemu-system-x86_64 -monitor stdio

and entering 'info mtree', when running on a slow console (eg a slow remote ssh session). The monitor would get into an indefinite loop writing the same data until it managed to send it all without getting EAGAIN.

---
 qemu-char.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
qemu-char.c +0 -3
index 1b7d5da..c2e24a5 100644
@@ -896,13 +896,13 @@ static int io_channel_send_full(QIOChannel *ioc,
             ioc, &iov, 1,
             fds, nfds, NULL);
         if (ret == QIO_CHANNEL_ERR_BLOCK) {
-            errno = EAGAIN;
-            return -1;
-        } else if (ret < 0) {

qemu-char.c static int io_channel_send_full(QIOChannel *ioc, · line 908

Quoted 10 lines
qemu-char.c +3 -0
             if (offset) {
                 return offset;
             }
 
+            errno = EAGAIN;
+            return -1;
+        } else if (ret < 0) {
             errno = EINVAL;
             return -1;
         }

Queued, thanks.

Paolo