All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wen Congyang <wency@cn.fujitsu.com>
To: qemu-devl <qemu-devel@nongnu.org>, Kevin Wolf <kwolf@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] iov: don't touch iov in iov_send_recv()
Date: Wed, 27 May 2015 16:00:32 +0800	[thread overview]
Message-ID: <556579A0.4060204@cn.fujitsu.com> (raw)
In-Reply-To: <555D39D2.4000705@cn.fujitsu.com>

Ping...

On 05/21/2015 09:50 AM, Wen Congyang wrote:
> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
> ---
>  include/qemu/iov.h |  2 +-
>  util/iov.c         | 14 +++++++++++++-
>  2 files changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/include/qemu/iov.h b/include/qemu/iov.h
> index 68d25f2..569b2c2 100644
> --- a/include/qemu/iov.h
> +++ b/include/qemu/iov.h
> @@ -75,7 +75,7 @@ size_t iov_memset(const struct iovec *iov, const unsigned int iov_cnt,
>   * For iov_send_recv() _whole_ area being sent or received
>   * should be within the iovec, not only beginning of it.
>   */
> -ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt,
> +ssize_t iov_send_recv(int sockfd, const struct iovec *iov, unsigned iov_cnt,
>                        size_t offset, size_t bytes, bool do_send);
>  #define iov_recv(sockfd, iov, iov_cnt, offset, bytes) \
>    iov_send_recv(sockfd, iov, iov_cnt, offset, bytes, false)
> diff --git a/util/iov.c b/util/iov.c
> index 2fb18e6..a0d5934 100644
> --- a/util/iov.c
> +++ b/util/iov.c
> @@ -133,7 +133,7 @@ do_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt, bool do_send)
>  #endif
>  }
>  
> -ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt,
> +ssize_t iov_send_recv(int sockfd, const struct iovec *_iov, unsigned iov_cnt,
>                        size_t offset, size_t bytes,
>                        bool do_send)
>  {
> @@ -141,6 +141,16 @@ ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt,
>      ssize_t ret;
>      size_t orig_len, tail;
>      unsigned niov;
> +    struct iovec *local_iov, *iov;
> +
> +    if (bytes <= 0) {
> +        return 0;
> +    }
> +
> +    local_iov = g_new0(struct iovec, iov_cnt);
> +    iov_copy(local_iov, iov_cnt, _iov, iov_cnt, offset, bytes);
> +    offset = 0;
> +    iov = local_iov;
>  
>      while (bytes > 0) {
>          /* Find the start position, skipping `offset' bytes:
> @@ -187,6 +197,7 @@ ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt,
>  
>          if (ret < 0) {
>              assert(errno != EINTR);
> +            g_free(local_iov);
>              if (errno == EAGAIN && total > 0) {
>                  return total;
>              }
> @@ -205,6 +216,7 @@ ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt,
>          bytes -= ret;
>      }
>  
> +    g_free(local_iov);
>      return total;
>  }
>  
> 

  reply	other threads:[~2015-05-27  7:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-21  1:50 [Qemu-devel] [PATCH] iov: don't touch iov in iov_send_recv() Wen Congyang
2015-05-27  8:00 ` Wen Congyang [this message]
2015-05-28 18:38   ` Dr. David Alan Gilbert
2015-06-23  3:43 ` Wen Congyang
2015-06-23 15:06 ` Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=556579A0.4060204@cn.fujitsu.com \
    --to=wency@cn.fujitsu.com \
    --cc=dgilbert@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.