add request cancelled flag
authorFelix Fietkau <nbd@openwrt.org>
Mon, 31 Jan 2011 01:52:12 +0000 (02:52 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Mon, 31 Jan 2011 01:54:39 +0000 (02:54 +0100)
libubus.c
libubus.h

index 7bf67a7a2a537d9068bc3ef36748454e79395207..b889e5a3cbd41841e6dde7068d2263c7ae004a16 100644 (file)
--- a/libubus.c
+++ b/libubus.c
@@ -178,7 +178,8 @@ static void ubus_process_req_data(struct ubus_request *req)
                data = list_first_entry(&req->pending,
                        struct ubus_pending_data, list);
                list_del(&data->list);
-               req->data_cb(req, data->type, data->data);
+               if (!req->cancelled)
+                       req->data_cb(req, data->type, data->data);
                free(data);
        }
 }
@@ -300,6 +301,8 @@ void ubus_abort_request(struct ubus_context *ctx, struct ubus_request *req)
        if (!list_empty(&req->list))
                return;
 
+       req->cancelled = true;
+       ubus_process_req_data(req);
        list_del(&req->list);
 }
 
@@ -331,6 +334,9 @@ int ubus_complete_request(struct ubus_context *ctx, struct ubus_request *req)
                if (req->status_msg)
                        return req->status_code;
 
+               if (req->cancelled)
+                       return UBUS_STATUS_NO_DATA;
+
                if (!get_next_msg(ctx, true))
                        return UBUS_STATUS_NO_DATA;
 
index bd3d736efd0578ab928c16d34ca259acb82b3ac2..9c07cae3d9689c6c6ff1f29d1be24c434ae1b5a6 100644 (file)
--- a/libubus.h
+++ b/libubus.h
@@ -88,6 +88,7 @@ struct ubus_request {
        bool status_msg;
        int status_code;
        bool blocked;
+       bool cancelled;
 
        uint32_t peer;
        uint32_t seq;