[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1/3] chardev: prevent extra connection attempt i
From: |
Marc-André Lureau |
Subject: |
Re: [Qemu-devel] [PATCH 1/3] chardev: prevent extra connection attempt in tcp_chr_machine_done_hook |
Date: |
Thu, 16 Aug 2018 17:41:49 +0200 |
Hi
On Thu, Aug 16, 2018 at 5:32 PM, Yury Kotov <address@hidden> wrote:
> Usually chardev connects to specified address during the initialization.
> But if reconnect_time is specified then connection will be postponed until
> machine done event.
>
> Thus if reconnect is specified and some device forces connection during
> initialization, tcp_chr_machine_done_hook will do useless connection attempt.
>
> So add a check to prevent it.
>
> Signed-off-by: Yury Kotov <address@hidden>
> Signed-off-by: Evgeny Yakovlev <address@hidden>
It would be better with a test case in tests/test-char.c, but lgtm,
Reviewed-by: Marc-André Lureau <address@hidden>
> ---
> chardev/char-socket.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/chardev/char-socket.c b/chardev/char-socket.c
> index efbad6e..116dcc4 100644
> --- a/chardev/char-socket.c
> +++ b/chardev/char-socket.c
> @@ -1165,7 +1165,10 @@ static int tcp_chr_machine_done_hook(Chardev *chr)
> {
> SocketChardev *s = SOCKET_CHARDEV(chr);
>
> - if (s->reconnect_time) {
> + /* It's possible that connection was established during the device
> + * initialization. So check if the socket is already connected to
> + * prevent extra connection attempt. */
> + if (!s->connected && s->reconnect_time) {
> tcp_chr_connect_async(chr);
> }
>
> --
> 2.7.4
>