[Spice-devel] [PATCH vd_agent_linux v2] vdagent: Stop trying to connect to the daemon after a while

Victor Toso victortoso at redhat.com
Mon Nov 19 12:04:44 UTC 2018


Hi,

On Mon, Nov 19, 2018 at 10:23:22AM +0000, Frediano Ziglio wrote:
> Do not try  indefinitely to connect to the daemon, should not
> take long to activate.

Why?

> 
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
>  src/vdagent/vdagent.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> Changes since v1:
> - log error when we reach the limit
> 
> diff --git a/src/vdagent/vdagent.c b/src/vdagent/vdagent.c
> index f7c8b72..7a58150 100644
> --- a/src/vdagent/vdagent.c
> +++ b/src/vdagent/vdagent.c
> @@ -53,6 +53,7 @@ typedef struct VDAgent {
>      struct vdagent_file_xfers *xfers;
>      struct udscs_connection *conn;
>      GIOChannel *x11_channel;
> +    guint connection_attempts;
>  
>      GMainLoop *loop;
>  } VDAgent;
> @@ -370,6 +371,11 @@ static gboolean vdagent_init_async_cb(gpointer user_data)
>                                  daemon_read_complete, daemon_disconnect_cb,
>                                  debug);
>      if (agent->conn == NULL) {
> +        // limit connection attempts, this will try for 5 minutes
> +        if (++agent->connection_attempts > 5 * 60) {
> +            syslog(LOG_ERR, "Attempted to contact daemon for 5 minutes, giving up");
> +            goto err_init;
> +        }
>          g_timeout_add_seconds(1, vdagent_init_async_cb, agent);
>          return G_SOURCE_REMOVE;
>      }
> -- 
> 2.17.2
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20181119/a6c2f409/attachment.sig>


More information about the Spice-devel mailing list