From 749aaf3b6d871da2d6a7edcbc9a3dce9226dc06d Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Mon, 31 Jan 2011 02:52:12 +0100 Subject: [PATCH] add request cancelled flag --- libubus.c | 8 +++++++- libubus.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/libubus.c b/libubus.c index 7bf67a7..b889e5a 100644 --- 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; diff --git a/libubus.h b/libubus.h index bd3d736..9c07cae 100644 --- 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; -- 2.25.1