X-Git-Url: http://git.openwrt.org/?a=blobdiff_plain;f=libubus.c;h=9463522488c11782dc9c15c79f1932b37e1149c1;hb=763b9b2cf293fb60b5c2ddf34e2500f95200b6b5;hp=bfbaeb6565905f2614e202fc8c25d265fd1ca52c;hpb=44a62711e0136a4a34f37d0b779c9c831818f9a4;p=project%2Fubus.git diff --git a/libubus.c b/libubus.c index bfbaeb6..9463522 100644 --- 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) @@ -277,6 +277,7 @@ static void ubus_default_connection_lost(struct ubus_context *ctx) int ubus_connect_ctx(struct ubus_context *ctx, const char *path) { + uloop_init(); memset(ctx, 0, sizeof(*ctx)); ctx->sock.fd = -1; @@ -294,6 +295,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; } @@ -358,7 +360,10 @@ struct ubus_context *ubus_connect(const char *path) void ubus_shutdown(struct ubus_context *ctx) { blob_buf_free(&b); + if (!ctx) + return; close(ctx->sock.fd); + uloop_timeout_cancel(&ctx->pending_timer); free(ctx->msgbuf.data); }