PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL=https://github.com/jow-/ucode.git
-PKG_SOURCE_DATE:=2025-08-26
-PKG_SOURCE_VERSION:=5f712ffd3f31f13ed4812cfb37c21dbef7a75e2b
-PKG_MIRROR_HASH:=6093ceb320854f4d38180f163fd702bceb8785ed6574aa145021eda82a9cf7b4
+PKG_SOURCE_DATE:=2025-09-29
+PKG_SOURCE_VERSION:=1090abb125490d2f541f68453cc251daf94f8b04
+PKG_MIRROR_HASH:=b68d893867add47b92d519a631c4e3bacec52eafae088b6a64ba3935f169bb15
PKG_LICENSE:=ISC
+++ /dev/null
-Date: Tue, 26 Aug 2025 10:17:22 +0200
-Subject: [PATCH] ubus: add connection functions to global scope
-
-Allows reusing a common global connection across modules
-
----
-
---- a/lib/ubus.c
-+++ b/lib/ubus.c
-@@ -511,16 +511,42 @@ uc_ubus_objects_cb(struct ubus_context *
- static bool
- _conn_get(uc_vm_t *vm, uc_ubus_connection_t **conn)
- {
-- uc_ubus_connection_t *c = uc_fn_thisval("ubus.connection");
-+ uc_ubus_connection_t *c;
-+ uc_value_t *res;
-
-- if (!c)
-- c = uc_fn_thisval("ubus.channel");
-- if (!c)
-- err_return(UBUS_STATUS_INVALID_ARGUMENT, "Invalid connection context");
-+ if (ucv_type(_uc_fn_this_res(vm)) == UC_OBJECT) {
-+ res = uc_vm_registry_get(vm, "ubus.connection");
-+ c = ucv_resource_data(res, "ubus.connection");
-+
-+ if (c && c->ctx.sock.fd >= 0)
-+ goto out;
-+
-+ c = uc_ubus_conn_alloc(vm, NULL, "ubus.connection");
-+ if (!c)
-+ return NULL;
-+
-+ if (ubus_connect_ctx(&c->ctx, NULL)) {
-+ ucv_put(c->res);
-+ err_return(UBUS_STATUS_UNKNOWN_ERROR, "Unable to connect to ubus socket");
-+ }
-+
-+ ubus_add_uloop(&c->ctx);
-
-- if (c->ctx.sock.fd < 0)
-- err_return(UBUS_STATUS_CONNECTION_FAILED, "Connection is closed");
-+ uc_vm_registry_set(vm, "ubus.connection", ucv_get(c->res));
-+ }
-+ else {
-+ c = uc_fn_thisval("ubus.connection");
-+ if (!c)
-+ c = uc_fn_thisval("ubus.channel");
-+
-+ if (!c)
-+ err_return(UBUS_STATUS_INVALID_ARGUMENT, "Invalid connection context");
-
-+ if (c->ctx.sock.fd < 0)
-+ err_return(UBUS_STATUS_CONNECTION_FAILED, "Connection is closed");
-+ }
-+
-+out:
- *conn = c;
-
- ok_return(true);
-@@ -2606,6 +2632,7 @@ static void free_request(void *ud) {
- void uc_module_init(uc_vm_t *vm, uc_value_t *scope)
- {
- uc_function_list_register(scope, global_fns);
-+ uc_function_list_register(scope, conn_fns);
-
- #define ADD_CONST(x) ucv_object_add(scope, #x, ucv_int64_new(UBUS_##x))
- ADD_CONST(STATUS_OK);