summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2022-06-29 20:16:59 +0200
committerGitHub <noreply@github.com>2022-06-29 20:16:59 +0200
commitf7c7aa615eb49c7a03e2ee2abe4df5bd18dd0f40 (patch)
tree31c0dd78b67ef47b696c68f9dac92e318298ab3a /lib
parent4334027e006a34bc1cf9632d3b1358d526b39bf8 (diff)
parent2e5426c0451ec03ef5fd6f41d7cfa26f84a857af (diff)
Merge pull request #91 from jow-/ubus-propagate-exceptions
ubus: end uloop on exceptions in managed code
Diffstat (limited to 'lib')
-rw-r--r--lib/ubus.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/ubus.c b/lib/ubus.c
index 2911d81..7f30fb8 100644
--- a/lib/ubus.c
+++ b/lib/ubus.c
@@ -740,6 +740,8 @@ uc_ubus_defer(uc_vm_t *vm, size_t nargs)
if (uc_vm_call(vm, false, 1) == EXCEPTION_NONE)
ucv_put(uc_vm_stack_pop(vm));
+ else
+ uloop_end();
free(defer);
}
@@ -888,6 +890,8 @@ uc_ubus_object_notify_data_cb(struct ubus_notify_request *req, int type, struct
if (uc_vm_call(notifyctx->vm, true, 2) == EXCEPTION_NONE)
ucv_put(uc_vm_stack_pop(notifyctx->vm));
+ else
+ uloop_end();
}
}
@@ -907,6 +911,8 @@ uc_ubus_object_notify_status_cb(struct ubus_notify_request *req, int idx, int re
if (uc_vm_call(notifyctx->vm, true, 2) == EXCEPTION_NONE)
ucv_put(uc_vm_stack_pop(notifyctx->vm));
+ else
+ uloop_end();
}
}
@@ -926,6 +932,8 @@ uc_ubus_object_notify_complete_cb(struct ubus_notify_request *req, int idx, int
if (uc_vm_call(notifyctx->vm, true, 2) == EXCEPTION_NONE)
ucv_put(uc_vm_stack_pop(notifyctx->vm));
+ else
+ uloop_end();
}
notifyctx->complete = true;
@@ -1203,7 +1211,6 @@ uc_ubus_handle_reply_common(struct ubus_context *ctx,
callctx->registry_index = request_reg_add(vm, ucv_get(reqobj), NULL);
}
-
/* Otherwise, when the function returned an object, treat it as
* reply data and conclude deferred request immediately */
else if (ucv_type(res) == UC_OBJECT) {
@@ -1238,9 +1245,10 @@ uc_ubus_handle_reply_common(struct ubus_context *ctx,
callctx->replied = true;
break;
- /* treat other exceptions as unknown error */
+ /* treat other exceptions as fatal and halt uloop */
default:
ubus_complete_deferred_request(ctx, &callctx->req, UBUS_STATUS_UNKNOWN_ERROR);
+ uloop_end();
callctx->replied = true;
break;
}