Patchwork [09/10] tcp_close(): check for close() errors too (v2)

login
register
mail settings
Submitter Eduardo Habkost
Date Nov. 10, 2011, 12:41 p.m.
Message ID <1320928908-19076-10-git-send-email-ehabkost@redhat.com>
Download mbox | patch
Permalink /patch/124880/
State New
Headers show

Comments

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

Changes v1 -> v2:
 - Use braces on if statement to match coding style

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

Patch

diff --git a/migration-tcp.c b/migration-tcp.c
index 5aa742c..cf6a9b8 100644
--- a/migration-tcp.c
+++ b/migration-tcp.c
@@ -40,12 +40,15 @@  static int socket_write(MigrationState *s, const void * buf, size_t size)
 
 static int tcp_close(MigrationState *s)
 {
+    int r = 0;
     DPRINTF("tcp_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 tcp_wait_for_connect(void *opaque)