ubus: ubus_free: clear pending timers before freeing context
[project/ubus.git] / libubus.c
index d52faff..51a1483 100644 (file)
--- a/libubus.c
+++ b/libubus.c
@@ -103,7 +103,7 @@ ubus_process_msg(struct ubus_context *ctx, struct ubus_msghdr_buf *buf, int fd)
                        break;
                }
 
-               ubus_process_obj_msg(ctx, buf);
+               ubus_process_obj_msg(ctx, buf, fd);
                break;
        case UBUS_MSG_MONITOR:
                if (ctx->monitor_cb)
@@ -294,6 +294,7 @@ int ubus_connect_ctx(struct ubus_context *ctx, const char *path)
        avl_init(&ctx->objects, ubus_cmp_id, false, NULL);
        if (ubus_reconnect(ctx, path)) {
                free(ctx->msgbuf.data);
+               ctx->msgbuf.data = NULL;
                return -1;
        }
 
@@ -361,6 +362,7 @@ void ubus_shutdown(struct ubus_context *ctx)
        if (!ctx)
                return;
        close(ctx->sock.fd);
+       uloop_timeout_cancel(&ctx->pending_timer);
        free(ctx->msgbuf.data);
 }