qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH for-2.7 2/2] net: make socket connect non-blocki


From: Cao jin
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
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0

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 <address@hidden>
---
  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 via email to

[Prev in Thread] Current Thread [Next in Thread]