From 61a5872fd66be718ad022102bf813d7e4e9324c5 Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Thu, 10 Nov 2011 10:41:47 -0200 Subject: tcp_close(): check for close() errors too (v2) 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 Signed-off-by: Anthony Liguori --- migration-tcp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'migration-tcp.c') diff --git a/migration-tcp.c b/migration-tcp.c index 5aa742c34b..cf6a9b83d6 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) -- cgit v1.2.1