At Fri, 16 Sep 2011 16:25:41 +0200,
Paolo Bonzini wrote:
> 
> When the other side is shutdown, read returns zero (writes return EPIPE).
> In this case, care must be taken to avoid infinite loops.  This error
> was already present in sheepdog.
> 
> Cc: MORITA Kazutaka <morita.kazut...@lab.ntt.co.jp>
> Signed-off-by: Paolo Bonzini <pbonz...@redhat.com>
> ---
>  cutils.c |    8 +++++++-
>  1 files changed, 7 insertions(+), 1 deletions(-)
> 
> diff --git a/cutils.c b/cutils.c
> index b302020..295187f 100644
> --- a/cutils.c
> +++ b/cutils.c
> @@ -501,8 +501,11 @@ static int do_sendv_recvv(int sockfd, struct iovec *iov, 
> int len, int offset,
>                  }
>                  break;
>              }
> -            iovlen--, p++;
> +            if (rc == 0) {
> +                break;
> +            }
>              ret += rc;
> +            iovlen--, p++;
>          }
>  #endif
>      }
> @@ -567,6 +570,9 @@ int coroutine_fn qemu_co_sendv(int sockfd, struct iovec 
> *iov,
>              }
>              break;
>          }
> +        if (ret == 0) {
> +            break;
> +        }
>          total += ret, len -= ret;
>      }

When EPIPE is set, write() returns -1 doesn't it?

It looks like qemu_co_recvv() handles a zero return correctly, so I
think this patch is not needed.


Thanks,

Kazutaka

Reply via email to