diff mbox

[02/11] iov: handle EOF in iov_send_recv

Message ID 1374568221-23147-3-git-send-email-morita.kazutaka@lab.ntt.co.jp
State New
Headers show

Commit Message

MORITA Kazutaka July 23, 2013, 8:30 a.m. UTC
Without this patch, iov_send_recv() never returns when do_send_recv()
returns zero.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
---
 util/iov.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Paolo Bonzini July 23, 2013, 11:28 a.m. UTC | #1
Il 23/07/2013 10:30, MORITA Kazutaka ha scritto:
> Without this patch, iov_send_recv() never returns when do_send_recv()
> returns zero.
> 
> Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
> ---
>  util/iov.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/util/iov.c b/util/iov.c
> index cc6e837..f705586 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;
> 

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

... and should also be in 1.5.2.

Paolo
Doug Goldstein Aug. 3, 2013, 3:48 a.m. UTC | #2
On Tue, Jul 23, 2013 at 6:28 AM, Paolo Bonzini <pbonzini@redhat.com> wrote:
> Il 23/07/2013 10:30, MORITA Kazutaka ha scritto:
>> Without this patch, iov_send_recv() never returns when do_send_recv()
>> returns zero.
>>
>> Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
>> ---
>>  util/iov.c | 6 ++++++
>>  1 file changed, 6 insertions(+)
>>
>> diff --git a/util/iov.c b/util/iov.c
>> index cc6e837..f705586 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;
>>
>
> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
>
> ... and should also be in 1.5.2.
>
> Paolo
>

Nudge so this doesn't get forgotten about. It hasn't hit master yet.
Kevin Wolf Aug. 5, 2013, 12:30 p.m. UTC | #3
Am 03.08.2013 um 05:48 hat Doug Goldstein geschrieben:
> On Tue, Jul 23, 2013 at 6:28 AM, Paolo Bonzini <pbonzini@redhat.com> wrote:
> > Il 23/07/2013 10:30, MORITA Kazutaka ha scritto:
> >> Without this patch, iov_send_recv() never returns when do_send_recv()
> >> returns zero.
> >>
> >> Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
> >> ---
> >>  util/iov.c | 6 ++++++
> >>  1 file changed, 6 insertions(+)
> >>
> >> diff --git a/util/iov.c b/util/iov.c
> >> index cc6e837..f705586 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;
> >>
> >
> > Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
> >
> > ... and should also be in 1.5.2.
> >
> > Paolo
> >
> 
> Nudge so this doesn't get forgotten about. It hasn't hit master yet.

Thanks, applied to the block branch.

Kevin
diff mbox

Patch

diff --git a/util/iov.c b/util/iov.c
index cc6e837..f705586 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;