qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Cao jin <caoj.fnst@cn.fujitsu.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>, qemu-devel@nongnu.org
Cc: jasowang@redhat.com, crobinso@redhat.com,
	ashijeetacharya@gmail.com, pbonzini@redhat.com,
	"Daniel P. Berrange" <berrange@redhat.com>
Subject: Re: [Qemu-devel] [PATCH for-2.7 2/2] net: make socket connect non-blocking again
Date: Tue, 23 Aug 2016 18:43:54 +0800	[thread overview]
Message-ID: <57BC28EA.8070700@cn.fujitsu.com> (raw)
In-Reply-To: <20160823094537.8782-3-marcandre.lureau@redhat.com>

Hi,
I just noticed you still using the old-style non-blocking connect(which 
will still block when query DNS), which will be removed (suggested by 
Daniel), but the patch is still on the way. So I guess maybe you should 
switch to QIOChannel way.

FYI:
http://lists.nongnu.org/archive/html/qemu-devel/2016-07/msg06386.html
http://lists.nongnu.org/archive/html/qemu-devel/2016-08/msg00046.html

     Cao jin

On 08/23/2016 05:45 PM, Marc-André Lureau wrote:
> Since commit 7e8449594c929, the socket connect code is blocking, because
> calling socket_connect() without callback is blocking. Make it
> non-blocking by adding a callback. Unfortunately, the callback needs
> many local variables that are not easy to get rid of (it can't easily
> create the qemu_new_net_client() earlier). By adding the callback, the
> socket is also made non-blocking. If the socket attempt succeeded
> immediately, the callback is still being called.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>   net/socket.c | 82 +++++++++++++++++++++++++++++++++++++++---------------------
>   1 file changed, 53 insertions(+), 29 deletions(-)
>

> +
> +static int net_socket_connect_init(NetClientState *peer,
> +                                   const char *model,
> +                                   const char *name,
> +                                   const char *host_str)
> +{
> +    socket_connect_data *c = g_new0(socket_connect_data, 1);
> +    int fd = -1;
> +    Error *local_error = NULL;
> +
> +    c->peer = peer;
> +    c->model = g_strdup(model);
> +    c->name = g_strdup(name);
> +    c->saddr = socket_parse(host_str, &local_error);
> +    if (c->saddr == NULL) {
> +        goto err;
> +    }
> +
> +    fd = socket_connect(c->saddr, &local_error, net_socket_connected, c);
> +    if (fd < 0) {
> +        goto err;
> +    }
> +
> +    return 0;
> +
> +err:
> +    error_report_err(local_error);
> +    socket_connect_data_free(c);
> +    return -1;
>   }
>
>   static int net_socket_mcast_init(NetClientState *peer,
>

  reply	other threads:[~2016-08-23 10:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-23  9:45 [Qemu-devel] [PATCH for-2.7 0/2] Fix net socket connect regressions Marc-André Lureau
2016-08-23  9:45 ` [Qemu-devel] [PATCH for-2.7 1/2] net: fix socket connect Marc-André Lureau
2016-08-23  9:45 ` [Qemu-devel] [PATCH for-2.7 2/2] net: make socket connect non-blocking again Marc-André Lureau
2016-08-23 10:43   ` Cao jin [this message]
2016-08-23 13:13     ` Daniel P. Berrange
2016-08-23 13:33       ` Marc-André Lureau
2016-08-30 12:07 ` [Qemu-devel] [PATCH for-2.7 0/2] Fix net socket connect regressions Paolo Bonzini

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=57BC28EA.8070700@cn.fujitsu.com \
    --to=caoj.fnst@cn.fujitsu.com \
    --cc=ashijeetacharya@gmail.com \
    --cc=berrange@redhat.com \
    --cc=crobinso@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=marcandre.lureau@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 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).