This fixes recursion problems on config reload in netifd and simplifies
application handling of requests
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
struct blob_attr *msg, int cmd, uint32_t peer);
void ubus_process_obj_msg(struct ubus_context*ctx, struct ubus_msghdr *hdr);
void ubus_process_req_msg(struct ubus_context *ctx, struct ubus_msghdr *hdr, int fd);
struct blob_attr *msg, int cmd, uint32_t peer);
void ubus_process_obj_msg(struct ubus_context*ctx, struct ubus_msghdr *hdr);
void ubus_process_req_msg(struct ubus_context *ctx, struct ubus_msghdr *hdr, int fd);
-void ubus_process_pending_msg(struct ubus_context *ctx);
void __hidden ubus_poll_data(struct ubus_context *ctx, int timeout);
void __hidden ubus_poll_data(struct ubus_context *ctx, int timeout);
if (!registered)
uloop_fd_delete(&ctx->sock);
if (!registered)
uloop_fd_delete(&ctx->sock);
- if (!ctx->stack_depth)
- ubus_process_pending_msg(ctx);
-
memcpy(&pending->hdr, hdr, sizeof(*hdr) + blob_raw_len(ubus_msghdr_data(hdr)));
list_add(&pending->list, &ctx->pending);
memcpy(&pending->hdr, hdr, sizeof(*hdr) + blob_raw_len(ubus_msghdr_data(hdr)));
list_add(&pending->list, &ctx->pending);
+ uloop_timeout_set(&ctx->pending_timer, 1);
case UBUS_MSG_INVOKE:
case UBUS_MSG_UNSUBSCRIBE:
case UBUS_MSG_NOTIFY:
case UBUS_MSG_INVOKE:
case UBUS_MSG_UNSUBSCRIBE:
case UBUS_MSG_NOTIFY:
- if (ctx->stack_depth > 2) {
+ if (ctx->stack_depth) {
ubus_queue_msg(ctx, hdr);
break;
}
ubus_queue_msg(ctx, hdr);
break;
}
-void __hidden ubus_process_pending_msg(struct ubus_context *ctx)
+static void ubus_process_pending_msg(struct uloop_timeout *timeout)
+ struct ubus_context *ctx = container_of(timeout, struct ubus_context, pending_timer);
struct ubus_pending_msg *pending;
struct ubus_pending_msg *pending;
- while (!list_empty(&ctx->pending)) {
+ while (!ctx->stack_depth && !list_empty(&ctx->pending)) {
pending = list_first_entry(&ctx->pending, struct ubus_pending_msg, list);
list_del(&pending->list);
ubus_process_msg(ctx, &pending->hdr, -1);
free(pending);
pending = list_first_entry(&ctx->pending, struct ubus_pending_msg, list);
list_del(&pending->list);
ubus_process_msg(ctx, &pending->hdr, -1);
free(pending);
- if (ctx->stack_depth > 2)
- break;
ctx->sock.fd = -1;
ctx->sock.cb = ubus_handle_data;
ctx->connection_lost = ubus_default_connection_lost;
ctx->sock.fd = -1;
ctx->sock.cb = ubus_handle_data;
ctx->connection_lost = ubus_default_connection_lost;
+ ctx->pending_timer.cb = ubus_process_pending_msg;
INIT_LIST_HEAD(&ctx->requests);
INIT_LIST_HEAD(&ctx->pending);
INIT_LIST_HEAD(&ctx->requests);
INIT_LIST_HEAD(&ctx->pending);
struct list_head pending;
struct uloop_fd sock;
struct list_head pending;
struct uloop_fd sock;
+ struct uloop_timeout pending_timer;
uint32_t local_id;
uint16_t request_seq;
uint32_t local_id;
uint16_t request_seq;