Skip to content

Commit bf46d11

Browse files
committed
ucode-mod-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>
1 parent bdc3c1a commit bf46d11

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
From: Felix Fietkau <nbd@nbd.name>
2+
Date: Sun, 4 Jan 2026 10:42:15 +0100
3+
Subject: [PATCH] ubus: complete pending requests when disconnecting locally
4+
5+
libubus only completes pending requests when the socket receives EOF.
6+
When explicitly disconnecting, we need to call ubus_flush_requests().
7+
8+
Signed-off-by: Felix Fietkau <nbd@nbd.name>
9+
---
10+
11+
--- a/CMakeLists.txt
12+
+++ b/CMakeLists.txt
13+
@@ -198,6 +198,7 @@ if(UBUS_SUPPORT)
14+
try_compile(HAVE_NEW_UBUS_STATUS_CODES
15+
${CMAKE_BINARY_DIR}
16+
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/test.c")
17+
+ check_function_exists(ubus_flush_requests HAVE_UBUS_FLUSH_REQUESTS)
18+
check_function_exists(uloop_timeout_remaining64 REMAINING64_FUNCTION_EXISTS)
19+
check_function_exists(ubus_channel_connect HAVE_CHANNEL_SUPPORT)
20+
file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/test2.c" "
21+
@@ -216,6 +217,9 @@ if(UBUS_SUPPORT)
22+
if(HAVE_NEW_UBUS_STATUS_CODES)
23+
add_definitions(-DHAVE_NEW_UBUS_STATUS_CODES)
24+
endif()
25+
+ if(HAVE_UBUS_FLUSH_REQUESTS)
26+
+ add_definitions(-DHAVE_UBUS_FLUSH_REQUESTS)
27+
+ endif()
28+
if (HAVE_UBUS_NEW_OBJ_CB)
29+
target_compile_definitions(ubus_lib PUBLIC HAVE_UBUS_NEW_OBJ_CB)
30+
endif()
31+
--- a/lib/ubus.c
32+
+++ b/lib/ubus.c
33+
@@ -2310,6 +2310,9 @@ uc_ubus_disconnect(uc_vm_t *vm, size_t n
34+
35+
conn_get(vm, &c);
36+
37+
+#ifdef HAVE_UBUS_FLUSH_REQUESTS
38+
+ ubus_flush_requests(&c->ctx);
39+
+#endif
40+
ubus_shutdown(&c->ctx);
41+
c->ctx.sock.fd = -1;
42+
uc_ubus_put_res(&c->res);

0 commit comments

Comments
 (0)