migration: Clean up use of g_poll() in socket_writev_buffer()
authorMarkus Armbruster <armbru@redhat.com>
Tue, 1 Dec 2015 13:34:14 +0000 (14:34 +0100)
committerJuan Quintela <quintela@redhat.com>
Wed, 2 Dec 2015 23:03:00 +0000 (00:03 +0100)
socket_writev_buffer() writes in a loop, using g_poll() to block.  If
g_poll() fails, it tries to write more before the file descriptor is
ready.  In theory, this could go into a tight loop.  In practice,
errors other than EINTR are really unlikely, and when they happen,
we're probably screwed anyway, so we can just as well loop.

Clean it up a bit: retry poll on EINTR, keep ignoring other errors.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
migration/qemu-file-unix.c

index c503b027a9f517398e35fa70287a6445518a3be7..6ca53e7d67f7ed244d216e8544d698296ec4f711 100644 (file)
@@ -72,7 +72,8 @@ static ssize_t socket_writev_buffer(void *opaque, struct iovec *iov, int iovcnt,
             pfd.fd = s->fd;
             pfd.events = G_IO_OUT | G_IO_ERR;
             pfd.revents = 0;
-            g_poll(&pfd, 1 /* 1 fd */, -1 /* no timeout */);
+            TFR(err = g_poll(&pfd, 1, -1 /* no timeout */));
+            /* Errors other than EINTR intentionally ignored */
         }
      }