[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 10/12] chardev: honour the reconnect setting in
From: |
Marc-André Lureau |
Subject: |
Re: [Qemu-devel] [PATCH 10/12] chardev: honour the reconnect setting in tcp_chr_wait_connected |
Date: |
Wed, 16 Jan 2019 01:22:08 +0400 |
Hi
On Tue, Jan 15, 2019 at 6:54 PM Daniel P. Berrangé <address@hidden> wrote:
>
> 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.
Obviously, that function is already a bit problematic, since it may
block the thread with no easy way to cancel (well, the _sync functions
in general..).
You change doesn't make it much worse, but it will now loop also in
case of errors. That's what reconnect_time is supposed to do, so
Reviewed-by: Marc-André Lureau <address@hidden>
>
> Signed-off-by: Daniel P. Berrangé <address@hidden>
> ---
> chardev/char-socket.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/chardev/char-socket.c b/chardev/char-socket.c
> index 96a60eb105..91d775e9c5 100644
> --- a/chardev/char-socket.c
> +++ b/chardev/char-socket.c
> @@ -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);
> + } else {
> + error_propagate(errp, err);
> + return -1;
> + }
> }
> }
> }
> --
> 2.20.1
>
- Re: [Qemu-devel] [PATCH 06/12] chardev: remove unused 'sioc' variable & cleanup paths, (continued)
- [Qemu-devel] [PATCH 07/12] chardev: split tcp_chr_wait_connected into two methods, Daniel P . Berrangé, 2019/01/15
- [Qemu-devel] [PATCH 08/12] chardev: split up qmp_chardev_open_socket connection code, Daniel P . Berrangé, 2019/01/15
- [Qemu-devel] [PATCH 09/12] chardev: use a state machine for socket connection state, Daniel P . Berrangé, 2019/01/15
- [Qemu-devel] [PATCH 10/12] chardev: honour the reconnect setting in tcp_chr_wait_connected, Daniel P . Berrangé, 2019/01/15
- Re: [Qemu-devel] [PATCH 10/12] chardev: honour the reconnect setting in tcp_chr_wait_connected,
Marc-André Lureau <=
- [Qemu-devel] [PATCH 11/12] chardev: disallow TLS/telnet/websocket with tcp_chr_wait_connected, Daniel P . Berrangé, 2019/01/15
- [Qemu-devel] [PATCH 12/12] chardev: fix race with client connections in tcp_chr_wait_connected, Daniel P . Berrangé, 2019/01/15
- [Qemu-devel] [PATCH 02/12] chardev: forbid 'reconnect' option with server sockets, Daniel P . Berrangé, 2019/01/15
- [Qemu-devel] [PATCH 05/12] chardev: ensure qemu_chr_parse_compat reports missing driver error, Daniel P . Berrangé, 2019/01/15
- [Qemu-devel] [PATCH 01/12] chardev: fix validation of options for QMP created chardevs, Daniel P . Berrangé, 2019/01/15