]> git.proxmox.com Git - mirror_qemu.git/commitdiff
chardev: honour the reconnect setting in tcp_chr_wait_connected
authorDaniel P. Berrangé <berrange@redhat.com>
Mon, 11 Feb 2019 18:24:38 +0000 (18:24 +0000)
committerMarc-André Lureau <marcandre.lureau@redhat.com>
Tue, 12 Feb 2019 16:35:56 +0000 (17:35 +0100)
If establishing a client connection fails, the tcp_chr_wait_connected
method should sleep for the reconnect timeout and then retry the
attempt. This ensures the callers don't immediately abort with an
error when the initial connection fails.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20190211182442.8542-13-berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
chardev/char-socket.c

index d6de5d2305267ed132e96df644835aa96da94d0a..7db20ff0a0266586a7501d6a69071a1efb8bb170 100644 (file)
@@ -957,8 +957,15 @@ static int tcp_chr_wait_connected(Chardev *chr, Error **errp)
         if (s->is_listen) {
             tcp_chr_accept_server_sync(chr);
         } else {
-            if (tcp_chr_connect_client_sync(chr, errp) < 0) {
-                return -1;
+            Error *err = NULL;
+            if (tcp_chr_connect_client_sync(chr, &err) < 0) {
+                if (s->reconnect_time) {
+                    error_free(err);
+                    g_usleep(s->reconnect_time * 1000ULL * 1000ULL);
+                } else {
+                    error_propagate(errp, err);
+                    return -1;
+                }
             }
         }
     }