lib: cancel reconnect timer on free
authorFelix Fietkau <nbd@nbd.name>
Tue, 14 Nov 2023 11:38:16 +0000 (12:38 +0100)
committerFelix Fietkau <nbd@nbd.name>
Tue, 14 Nov 2023 11:38:16 +0000 (12:38 +0100)
Signed-off-by: Felix Fietkau <nbd@nbd.name>
lib.c

diff --git a/lib.c b/lib.c
index 7be36bb7803908fcb0f771c35a80a4ba4f095487..c545816fe3a9ad9f9401a265b538d8635eaa257f 100644 (file)
--- a/lib.c
+++ b/lib.c
@@ -713,7 +713,7 @@ void __udebug_disconnect(struct udebug *ctx, bool reconnect)
        close(ctx->fd.fd);
        ctx->fd.fd = -1;
        ctx->poll_handle = -1;
-       if (ctx->reconnect.cb)
+       if (ctx->reconnect.cb && reconnect)
                uloop_timeout_set(&ctx->reconnect, 1);
 }
 
@@ -726,6 +726,7 @@ void udebug_free(struct udebug *ctx)
        ctx->socket_path = NULL;
 
        __udebug_disconnect(ctx, false);
+       uloop_timeout_cancel(&ctx->reconnect);
 
        while (!list_empty(&ctx->local_rings)) {
                buf = list_first_entry(&ctx->local_rings, struct udebug_buf, list);