From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org, patches@linaro.org,
Samuel Thibault <samuel.thibault@ens-lyon.org>,
Jan Kiszka <jan.kiszka@siemens.com>
Subject: Re: [Qemu-devel] [PATCH 1/2] slirp: Handle error returns from slirp_send() in sosendoob()
Date: Tue, 11 Jul 2017 19:05:09 +0100 [thread overview]
Message-ID: <20170711180509.GG2223@work-vm> (raw)
In-Reply-To: <1496679576-14336-2-git-send-email-peter.maydell@linaro.org>
* Peter Maydell (peter.maydell@linaro.org) wrote:
> The code in sosendoob() assumes that slirp_send() always
> succeeds, but it might return an OS error code (for instance
> if the other end has disconnected). Catch these and return
> the caller either -1 on error or the number of urgent bytes
> actually written. (None of the callers check this return
> value currently, though.)
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
That looks OK to me; the changes don't change the datastructure
usage at all - it's just the updated or so_urgc if it worked.
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> ---
> slirp/socket.c | 29 ++++++++++++++++++-----------
> 1 file changed, 18 insertions(+), 11 deletions(-)
>
> diff --git a/slirp/socket.c b/slirp/socket.c
> index 3b49a69..a17caa9 100644
> --- a/slirp/socket.c
> +++ b/slirp/socket.c
> @@ -345,33 +345,40 @@ sosendoob(struct socket *so)
> if (sb->sb_rptr < sb->sb_wptr) {
> /* We can send it directly */
> n = slirp_send(so, sb->sb_rptr, so->so_urgc, (MSG_OOB)); /* |MSG_DONTWAIT)); */
> - so->so_urgc -= n;
> -
> - DEBUG_MISC((dfd, " --- sent %d bytes urgent data, %d urgent bytes left\n", n, so->so_urgc));
> } else {
> /*
> * Since there's no sendv or sendtov like writev,
> * we must copy all data to a linear buffer then
> * send it all
> */
> + uint32_t urgc = so->so_urgc;
> len = (sb->sb_data + sb->sb_datalen) - sb->sb_rptr;
> - if (len > so->so_urgc) len = so->so_urgc;
> + if (len > urgc) {
> + len = urgc;
> + }
> memcpy(buff, sb->sb_rptr, len);
> - so->so_urgc -= len;
> - if (so->so_urgc) {
> + urgc -= len;
> + if (urgc) {
> n = sb->sb_wptr - sb->sb_data;
> - if (n > so->so_urgc) n = so->so_urgc;
> + if (n > urgc) {
> + n = urgc;
> + }
> memcpy((buff + len), sb->sb_data, n);
> - so->so_urgc -= n;
> len += n;
> }
> n = slirp_send(so, buff, len, (MSG_OOB)); /* |MSG_DONTWAIT)); */
> + }
> +
> #ifdef DEBUG
> - if (n != len)
> - DEBUG_ERROR((dfd, "Didn't send all data urgently XXXXX\n"));
> + if (n != len) {
> + DEBUG_ERROR((dfd, "Didn't send all data urgently XXXXX\n"));
> + }
> #endif
> - DEBUG_MISC((dfd, " ---2 sent %d bytes urgent data, %d urgent bytes left\n", n, so->so_urgc));
> + if (n < 0) {
> + return n;
> }
> + so->so_urgc -= n;
> + DEBUG_MISC((dfd, " ---2 sent %d bytes urgent data, %d urgent bytes left\n", n, so->so_urgc));
>
> sb->sb_cc -= n;
> sb->sb_rptr += n;
> --
> 2.7.4
>
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
next prev parent reply other threads:[~2017-07-11 18:05 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-05 16:19 [Qemu-devel] [PATCH 0/2] slirp: handle errors in sosendoob() Peter Maydell
2017-06-05 16:19 ` [Qemu-devel] [PATCH 1/2] slirp: Handle error returns from slirp_send() " Peter Maydell
2017-07-11 18:05 ` Dr. David Alan Gilbert [this message]
2017-07-11 23:24 ` [Qemu-devel] [1/2] " Samuel Thibault
2017-06-05 16:19 ` [Qemu-devel] [PATCH 2/2] slirp: Handle error returns from sosendoob() Peter Maydell
2017-07-11 18:46 ` Dr. David Alan Gilbert
2017-07-11 20:38 ` Peter Maydell
2017-07-11 23:24 ` [Qemu-devel] [2/2] " Samuel Thibault
2017-06-05 18:22 ` [Qemu-devel] [PATCH 0/2] slirp: handle errors in sosendoob() no-reply
2017-06-26 12:24 ` Peter Maydell
2017-07-09 21:21 ` Peter Maydell
2017-07-09 21:56 ` Samuel Thibault
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=20170711180509.GG2223@work-vm \
--to=dgilbert@redhat.com \
--cc=jan.kiszka@siemens.com \
--cc=patches@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=samuel.thibault@ens-lyon.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).