Patchwork [10/10] unix_close(): check for close() errors too

login
register
mail settings
Submitter Eduardo Habkost
Date Nov. 9, 2011, 10:03 p.m.
Message ID <1320876205-16113-11-git-send-email-ehabkost@redhat.com>
Download mbox | patch
Permalink /patch/124714/
State New
Headers show

Comments

Eduardo Habkost - Nov. 9, 2011, 10:03 p.m.
In case close() fails, we want to report the error back.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 migration-unix.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

Patch

diff --git a/migration-unix.c b/migration-unix.c
index 8596353..197285c 100644
--- a/migration-unix.c
+++ b/migration-unix.c
@@ -40,12 +40,14 @@  static int unix_write(MigrationState *s, const void * buf, size_t size)
 
 static int unix_close(MigrationState *s)
 {
+    int r = 0;
     DPRINTF("unix_close\n");
     if (s->fd != -1) {
-        close(s->fd);
+        if (close(s->fd) < 0)
+            r = -errno;
         s->fd = -1;
     }
-    return 0;
+    return r;
 }
 
 static void unix_wait_for_connect(void *opaque)