Skip to contentSkip to conversation

migration: Clean up use of g_poll() in socket_writev_buffer()

PATCH In review Markus Armbruster 3 participants 3 messages Dec 1, 2015 – Dec 2, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 migration: Clean up use of g_poll() in socket_writev_buffer()

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.

---
Let me stress once again: this is *not* a bug fix, it's cleanup! If you don't like it, you can safely ignore it. We'll then mark the spot as intentional in the Coverity dashboard.

 migration/qemu-file-unix.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
migration/qemu-file-unix.c +2 -1
index c503b02..6ca53e7 100644
@@ -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 */
         }
      }
 
Signature · 1 line
2.4.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 23 lines · Markus Armbruster

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.

---
Let me stress once again: this is *not* a bug fix, it's cleanup! If you don't like it, you can safely ignore it. We'll then mark the spot as intentional in the Coverity dashboard.

 migration/qemu-file-unix.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
migration/qemu-file-unix.c +0 -0
index c503b02..6ca53e7 100644

migration/qemu-file-unix.c static ssize_t socket_writev_buffer(void *opaque, struct iovec *iov, int iovcnt, · line 79

Quoted 9 lines
migration/qemu-file-unix.c +2 -1
@@ -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 */
         }
      }
 
Reviewed-by on v1 1/1
#2 lore raw
In reply to Markus Armbruster
Quoted 9 lines · Markus Armbruster

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.

Included in next migration pull request.

Thanks.

Quoted 21 lines

---
Let me stress once again: this is *not* a bug fix, it's cleanup! If you don't like it, you can safely ignore it. We'll then mark the spot as intentional in the Coverity dashboard.

 migration/qemu-file-unix.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
migration/qemu-file-unix.c +2 -1
index c503b02..6ca53e7 100644
@@ -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 */
         }
      }