qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: Juan Quintela <quintela@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/2] Use getaddrinfo for migration
Date: Wed, 16 Mar 2011 22:06:05 +0000	[thread overview]
Message-ID: <AANLkTi=dvpTHhP8f8FdxOObFCjSszcuD+X5hCyYRhfsH@mail.gmail.com> (raw)
In-Reply-To: <414060358dedfe8455354ef2fc1a90e6254abe16.1300297944.git.quintela@redhat.com>

On 16 March 2011 21:01, Juan Quintela <quintela@redhat.com> wrote:
> +static int tcp_server_bind(int fd, struct addrinfo *rp)
> +{
> +    int val = 1;
> +    int ret;
> +
> +    /* allow fast reuse */
> +    setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (const char *)&val,
> +               sizeof(val));
> +
> +    ret = bind(fd, rp->ai_addr, rp->ai_addrlen);
> +
> +    if (ret == -1) {
> +        ret = -socket_error();
> +    }
> +    return ret;
> +
> +}

I know this is just moved code, but does this do the right thing
on Windows? Windows semantics for SO_REUSEADDR are completely
different from the Unix ones:
http://blogs.msdn.com/b/wndp/archive/2005/08/03/anthony-jones.aspx
http://msdn.microsoft.com/en-us/library/ms740618%28VS.85%29.aspx

Roughly, Unix default behaviour is like Windows SO_EXCLUSIVEADDRUSE;
Unix SO_REUSEADDR is like Windows default behaviour; and Windows
SO_REUSEADDR behaviour is really weird and you don't want it.

(I think Cygwin has a workaround for this to give unix semantics,
but Windows qemu builds as a mingw app, so we get the MS semantics,
right?)

> +static int tcp_start_common(const char *str, int *fd, bool server)
> +{
[...]
> +    s = getaddrinfo(name, service, &hints, &result);
> +    if (s != 0) {
> +        fprintf(stderr, "qemu: getaddrinfo: %s\n", gai_strerror(s));
> +        return -EINVAL;
> +    }

It seems a bit odd to have a low level utility routine printing
diagnostics to stderr rather than just returning the error
details to its caller somehow. Ditto the other fprintf later.

-- PMM

  reply	other threads:[~2011-03-16 22:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-16 21:01 [Qemu-devel] [PATCH 0/2] Allow ipv6 for migration Juan Quintela
2011-03-16 21:01 ` [Qemu-devel] [PATCH 1/2] Use getaddrinfo " Juan Quintela
2011-03-16 22:06   ` Peter Maydell [this message]
2011-03-16 22:20     ` [Qemu-devel] " Juan Quintela
2011-03-16 21:01 ` [Qemu-devel] [PATCH 2/2] net/socket: allow ipv6 for net_socket_listen_init and net_socket_connect_init Juan Quintela
2011-03-16 21:30   ` Peter Maydell
2011-03-16 22:22     ` [Qemu-devel] " Juan Quintela

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='AANLkTi=dvpTHhP8f8FdxOObFCjSszcuD+X5hCyYRhfsH@mail.gmail.com' \
    --to=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /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).