From 840042901710c2dc1a3ac3e5af9bed449c339701 Mon Sep 17 00:00:00 2001 From: MORITA Kazutaka Date: Tue, 23 Jul 2013 17:30:12 +0900 Subject: iov: handle EOF in iov_send_recv Without this patch, iov_send_recv() never returns when do_send_recv() returns zero. Signed-off-by: MORITA Kazutaka Reviewed-by: Paolo Bonzini Signed-off-by: Kevin Wolf --- util/iov.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'util') diff --git a/util/iov.c b/util/iov.c index cc6e837c83..f705586808 100644 --- a/util/iov.c +++ b/util/iov.c @@ -202,6 +202,12 @@ ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt, return -1; } + if (ret == 0 && !do_send) { + /* recv returns 0 when the peer has performed an orderly + * shutdown. */ + break; + } + /* Prepare for the next iteration */ offset += ret; total += ret; -- cgit v1.2.1