Skip to contentSkip to conversation

chardev: fix handling of EAGAIN for TCP chardev

PATCH Applied Daniel P. Berrangé 4 participants 4 messages Feb 22, 2018 – Mar 12, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 chardev: fix handling of EAGAIN for TCP chardev

When this commit was applied

commit 9894dc0cdcc397ee5b26370bc53da6d360a363c2
Author: Daniel P. Berrange <[email protected]>
Date: Tue Jan 19 11:14:29 2016 +0000

char: convert from GIOChannel to QIOChannel

The tcp_chr_recv() function was changed to return QIO_CHANNEL_ERR_BLOCK which corresonds to -2. As such the handling for EAGAIN was able to be removed from tcp_chr_read(). Unfortunately in a later commit:

commit b6572b4f97a7b126c7b24e165893ed9fe3d72e1f
Author: Marc-André Lureau <[email protected]>
Date: Fri Mar 11 18:55:24 2016 +0100

char: translate from QIOChannel error to errno

The tcp_chr_recv() function was changed back to return -1, with errno set to EAGAIN, without also re-addding support for this to tcp_chr_read()

---
 chardev/char-socket.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
chardev/char-socket.c +1 -1
index bdd6cff5f6..b15682c362 100644
@@ -449,7 +449,7 @@ static gboolean tcp_chr_read(QIOChannel *chan, GIOCondition cond, void *opaque)
         len = s->max_size;
     }
     size = tcp_chr_recv(chr, (void *)buf, len);
-    if (size == 0 || size == -1) {
+    if (size == 0 || (size == -1 && errno != EAGAIN)) {
         /* connection closed */
         tcp_chr_disconnect(chr);
     } else if (size > 0) {
Signature · 1 line
2.14.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 16 lines · Daniel P. Berrangé

When this commit was applied

commit 9894dc0cdcc397ee5b26370bc53da6d360a363c2
Author: Daniel P. Berrange <[email protected]>
Date: Tue Jan 19 11:14:29 2016 +0000

char: convert from GIOChannel to QIOChannel

The tcp_chr_recv() function was changed to return QIO_CHANNEL_ERR_BLOCK which corresonds to -2. As such the handling for EAGAIN was able to be removed from tcp_chr_read(). Unfortunately in a later commit:

commit b6572b4f97a7b126c7b24e165893ed9fe3d72e1f
Author: Marc-André Lureau <[email protected]>
Date: Fri Mar 11 18:55:24 2016 +0100

Quoted 7 lines

char: translate from QIOChannel error to errno

The tcp_chr_recv() function was changed back to return -1, with errno set to EAGAIN, without also re-addding support for this to tcp_chr_read()

Quoted 21 lines
---
 chardev/char-socket.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
chardev/char-socket.c +1 -2
index bdd6cff5f6..b15682c362 100644
@@ -449,7 +449,7 @@ static gboolean tcp_chr_read(QIOChannel *chan, GIOCondition cond, void *opaque)
         len = s->max_size;
     }
     size = tcp_chr_recv(chr, (void *)buf, len);
-    if (size == 0 || size == -1) {
+    if (size == 0 || (size == -1 && errno != EAGAIN)) {
         /* connection closed */
         tcp_chr_disconnect(chr);
     } else if (size > 0) {
--

2.14.3

Signature · 1 line
Marc-André Lureau
#2 lore raw
In reply to Daniel P. Berrangé

Thank you, Daniel!

22.02.2018, 15:14, "Daniel P. Berrangé" <[email protected]>:

Quoted 42 lines

When this commit was applied

  commit 9894dc0cdcc397ee5b26370bc53da6d360a363c2
  Author: Daniel P. Berrange <[email protected]>
  Date: Tue Jan 19 11:14:29 2016 +0000

    char: convert from GIOChannel to QIOChannel

The tcp_chr_recv() function was changed to return QIO_CHANNEL_ERR_BLOCK which corresonds to -2. As such the handling for EAGAIN was able to be removed from tcp_chr_read(). Unfortunately in a later commit:

  commit b6572b4f97a7b126c7b24e165893ed9fe3d72e1f
  Author: Marc-André Lureau <[email protected]>
  Date: Fri Mar 11 18:55:24 2016 +0100

    char: translate from QIOChannel error to errno

The tcp_chr_recv() function was changed back to return -1, with errno set to EAGAIN, without also re-addding support for this to tcp_chr_read()

---
 chardev/char-socket.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
chardev/char-socket.c +1 -2
index bdd6cff5f6..b15682c362 100644
@@ -449,7 +449,7 @@ static gboolean tcp_chr_read(QIOChannel *chan, GIOCondition cond, void *opaque)
          len = s->max_size;
      }
      size = tcp_chr_recv(chr, (void *)buf, len);
- if (size == 0 || size == -1) {
+ if (size == 0 || (size == -1 && errno != EAGAIN)) {
          /* connection closed */
          tcp_chr_disconnect(chr);
      } else if (size > 0) {
--

2.14.3

#3 lore raw
In reply to Daniel P. Berrangé
Quoted 33 lines · Daniel P. Berrangé

When this commit was applied

commit 9894dc0cdcc397ee5b26370bc53da6d360a363c2
Author: Daniel P. Berrange <[email protected]>
Date: Tue Jan 19 11:14:29 2016 +0000

char: convert from GIOChannel to QIOChannel

The tcp_chr_recv() function was changed to return QIO_CHANNEL_ERR_BLOCK which corresonds to -2. As such the handling for EAGAIN was able to be removed from tcp_chr_read(). Unfortunately in a later commit:

commit b6572b4f97a7b126c7b24e165893ed9fe3d72e1f
Author: Marc-André Lureau <[email protected]>
Date: Fri Mar 11 18:55:24 2016 +0100

char: translate from QIOChannel error to errno

The tcp_chr_recv() function was changed back to return -1, with errno set to EAGAIN, without also re-addding support for this to tcp_chr_read()

---
 chardev/char-socket.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
chardev/char-socket.c +0 -0
index bdd6cff5f6..b15682c362 100644

chardev/char-socket.c static gboolean tcp_chr_read(QIOChannel *chan, GIOCondition cond, void *opaque) · line 455

Quoted 8 lines
chardev/char-socket.c +1 -1
@@ -449,7 +449,7 @@ static gboolean tcp_chr_read(QIOChannel *chan, GIOCondition cond, void *opaque)
         len = s->max_size;
     }
     size = tcp_chr_recv(chr, (void *)buf, len);
-    if (size == 0 || size == -1) {
+    if (size == 0 || (size == -1 && errno != EAGAIN)) {
         /* connection closed */
         tcp_chr_disconnect(chr);
     } else if (size > 0) {

Queued, thanks.

Paolo