[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [sheepdog] [PATCH v4 03/10] sheepdog: check return valu
From: |
MORITA Kazutaka |
Subject: |
Re: [Qemu-devel] [sheepdog] [PATCH v4 03/10] sheepdog: check return values of qemu_co_recv/send correctly |
Date: |
Fri, 02 Aug 2013 15:09:03 +0900 |
User-agent: |
Wanderlust/2.15.9 (Almost Unreal) Emacs/23.2 Mule/6.0 (HANACHIRUSATO) |
At Tue, 30 Jul 2013 15:48:02 +0200,
Stefan Hajnoczi wrote:
>
> On Fri, Jul 26, 2013 at 03:10:45PM +0900, MORITA Kazutaka wrote:
> > If qemu_co_recv/send doesn't return the specified length, it means
> > that an error happened.
> >
> > Tested-and-reviewed-by: Liu Yuan <address@hidden>
> > Signed-off-by: MORITA Kazutaka <address@hidden>
> > ---
> > block/sheepdog.c | 16 ++++++++--------
> > 1 file changed, 8 insertions(+), 8 deletions(-)
> >
> > diff --git a/block/sheepdog.c b/block/sheepdog.c
> > index 6a41ad9..c6e9b89 100644
> > --- a/block/sheepdog.c
> > +++ b/block/sheepdog.c
> > @@ -489,13 +489,13 @@ static coroutine_fn int send_co_req(int sockfd,
> > SheepdogReq *hdr, void *data,
> > int ret;
> >
> > ret = qemu_co_send(sockfd, hdr, sizeof(*hdr));
> > - if (ret < sizeof(*hdr)) {
> > + if (ret != sizeof(*hdr)) {
> > error_report("failed to send a req, %s", strerror(errno));
>
> Does this rely on qemu_co_send_recv() getting ret=-1 errno=EPIPE from
> iov_send_recv()? I want to check that I understand what happens when
> the socket is closed by the other side.
Yes, when the socket is closed by the peer, qemu_co_send_recv()
returns a short write (if some bytes are already sent) or -1 (if no
data is sent). The current sheepdog driver doesn't work correctly for
the latter case because it compares -1 and an unsigned value.
This doesn't happen for the current qemu-io and qemu-img because they
terminate with SIGPIPE when the connection is closed by the peer.
Thanks,
Kazutaka
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [Qemu-devel] [sheepdog] [PATCH v4 03/10] sheepdog: check return values of qemu_co_recv/send correctly,
MORITA Kazutaka <=