qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 2/4] qemu-char: retry g_poll on EINTR
Date: Wed,  2 Dec 2015 16:15:38 +0100	[thread overview]
Message-ID: <1449069340-10419-3-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1449069340-10419-1-git-send-email-pbonzini@redhat.com>

This is a case where pty_chr_update_read_handler_locked's lack
of error checking can produce incorrect values.  We are not using
SIGUSR1 anymore, so this is quite theoretical, but easy to fix.

Reported-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 qemu-char.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/qemu-char.c b/qemu-char.c
index 5448b0f..2969c44 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -1241,11 +1241,16 @@ static void pty_chr_update_read_handler_locked(CharDriverState *chr)
 {
     PtyCharDriver *s = chr->opaque;
     GPollFD pfd;
+    int rc;
 
     pfd.fd = g_io_channel_unix_get_fd(s->fd);
     pfd.events = G_IO_OUT;
     pfd.revents = 0;
-    g_poll(&pfd, 1, 0);
+    do {
+        rc = g_poll(&pfd, 1, 0);
+    } while (rc == -1 && errno == EINTR);
+    assert(rc >= 0);
+
     if (pfd.revents & G_IO_HUP) {
         pty_chr_state(chr, 0);
     } else {
-- 
2.5.0

  parent reply	other threads:[~2015-12-02 15:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-02 15:15 [Qemu-devel] [PULL 0/4] QEMU changes for 2.5.0-rc3 Paolo Bonzini
2015-12-02 15:15 ` [Qemu-devel] [PULL 1/4] exec: Stop using memory after free Paolo Bonzini
2015-12-02 15:15 ` Paolo Bonzini [this message]
2015-12-02 15:15 ` [Qemu-devel] [PULL 3/4] main-loop: suppress warnings under qtest Paolo Bonzini
2015-12-02 15:15 ` [Qemu-devel] [PULL 4/4] translate-all: ensure host page mask is always extended with 1's Paolo Bonzini
2015-12-02 16:24 ` [Qemu-devel] [PULL 0/4] QEMU changes for 2.5.0-rc3 Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1449069340-10419-3-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).