X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fubus.git;a=blobdiff_plain;f=libubus-obj.c;h=c1931b314ef24b40f15d06ed6b0c16fcde17155e;hp=9261b83246f26ea83167659970f71f504fa2df24;hb=HEAD;hpb=6d1ea6c33d321e4840b05986b6ce8e214bd1ba3a diff --git a/libubus-obj.c b/libubus-obj.c index 9261b83..c1931b3 100644 --- a/libubus-obj.c +++ b/libubus-obj.c @@ -31,7 +31,8 @@ ubus_process_unsubscribe(struct ubus_context *ctx, struct ubus_msghdr *hdr, if (s->remove_cb) s->remove_cb(ctx, s, blob_get_u32(attrbuf[UBUS_ATTR_TARGET])); - close(fd); + if (fd >= 0) + close(fd); } static void @@ -45,7 +46,8 @@ ubus_process_notify(struct ubus_context *ctx, struct ubus_msghdr *hdr, if (obj->subscribe_cb) obj->subscribe_cb(ctx, obj); - close(fd); + if (fd >= 0) + close(fd); } static void ubus_process_invoke(struct ubus_context *ctx, struct ubus_msghdr *hdr, @@ -95,7 +97,8 @@ found: ret = obj->methods[method].handler(ctx, obj, &req, blob_data(attrbuf[UBUS_ATTR_METHOD]), attrbuf[UBUS_ATTR_DATA]); - close(req.req_fd); + if (req.req_fd >= 0) + close(req.req_fd); if (req.deferred || no_reply) return;