]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
ucode-mod-ubus: complete pending requests when disconnecting locally
authorFelix Fietkau <nbd@nbd.name>
Sun, 4 Jan 2026 18:21:41 +0000 (18:21 +0000)
committerFelix Fietkau <nbd@nbd.name>
Mon, 5 Jan 2026 11:43:40 +0000 (12:43 +0100)
libubus only completes pending requests when the socket receives EOF.
When explicitly disconnecting, we need to call ubus_flush_requests().

Signed-off-by: Felix Fietkau <nbd@nbd.name>
package/utils/ucode/patches/130-ubus-complete-pending-requests-when-disconnecting-lo.patch [new file with mode: 0644]

diff --git a/package/utils/ucode/patches/130-ubus-complete-pending-requests-when-disconnecting-lo.patch b/package/utils/ucode/patches/130-ubus-complete-pending-requests-when-disconnecting-lo.patch
new file mode 100644 (file)
index 0000000..e3d2f92
--- /dev/null
@@ -0,0 +1,42 @@
+From: Felix Fietkau <nbd@nbd.name>
+Date: Sun, 4 Jan 2026 10:42:15 +0100
+Subject: [PATCH] ubus: complete pending requests when disconnecting locally
+
+libubus only completes pending requests when the socket receives EOF.
+When explicitly disconnecting, we need to call ubus_flush_requests().
+
+Signed-off-by: Felix Fietkau <nbd@nbd.name>
+---
+
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -198,6 +198,7 @@ if(UBUS_SUPPORT)
+   try_compile(HAVE_NEW_UBUS_STATUS_CODES
+     ${CMAKE_BINARY_DIR}
+     "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/test.c")
++  check_function_exists(ubus_flush_requests HAVE_UBUS_FLUSH_REQUESTS)
+   check_function_exists(uloop_timeout_remaining64 REMAINING64_FUNCTION_EXISTS)
+   check_function_exists(ubus_channel_connect HAVE_CHANNEL_SUPPORT)
+   file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/test2.c" "
+@@ -216,6 +217,9 @@ if(UBUS_SUPPORT)
+   if(HAVE_NEW_UBUS_STATUS_CODES)
+     add_definitions(-DHAVE_NEW_UBUS_STATUS_CODES)
+   endif()
++  if(HAVE_UBUS_FLUSH_REQUESTS)
++    add_definitions(-DHAVE_UBUS_FLUSH_REQUESTS)
++  endif()
+   if (HAVE_UBUS_NEW_OBJ_CB)
+     target_compile_definitions(ubus_lib PUBLIC HAVE_UBUS_NEW_OBJ_CB)
+   endif()
+--- a/lib/ubus.c
++++ b/lib/ubus.c
+@@ -2310,6 +2310,9 @@ uc_ubus_disconnect(uc_vm_t *vm, size_t n
+       conn_get(vm, &c);
++#ifdef HAVE_UBUS_FLUSH_REQUESTS
++      ubus_flush_requests(&c->ctx);
++#endif
+       ubus_shutdown(&c->ctx);
+       c->ctx.sock.fd = -1;
+       uc_ubus_put_res(&c->res);