summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2024-05-02 10:51:43 +0200
committerGitHub <noreply@github.com>2024-05-02 10:51:43 +0200
commit25d41bae3c571b993022767f77e4bdfc2d8e5e3d (patch)
tree7c72983ba74c97bee00b3073358bd4943915e45e
parent69dd962870097dcda43af9bee0494ea75bcc0e31 (diff)
parentf211d5ac666fbde1fb2bbf3de7065344f5108bad (diff)
Merge pull request #198 from nbd168/ubus-uloop-fix
ubus: fix uc_ubus_have_uloop for eloop+uloop combination
-rw-r--r--CMakeLists.txt5
-rw-r--r--lib/ubus.c5
2 files changed, 10 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1ffcadc..adc04ec 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -159,6 +159,7 @@ if(UBUS_SUPPORT)
set_target_properties(ubus_lib PROPERTIES OUTPUT_NAME ubus PREFIX "")
target_link_options(ubus_lib PRIVATE ${UCODE_MODULE_LINK_OPTIONS})
target_link_libraries(ubus_lib ${libubus} ${libblobmsg_json})
+ list(APPEND CMAKE_REQUIRED_LIBRARIES ${libubox})
file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/test.c" "
#include <libubus.h>
int main() { return UBUS_STATUS_NO_MEMORY; }
@@ -166,9 +167,13 @@ if(UBUS_SUPPORT)
try_compile(HAVE_NEW_UBUS_STATUS_CODES
${CMAKE_BINARY_DIR}
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/test.c")
+ check_symbol_exists(uloop_fd_set_cb "libubox/uloop.h" FD_SET_CB_EXISTS)
if(HAVE_NEW_UBUS_STATUS_CODES)
add_definitions(-DHAVE_NEW_UBUS_STATUS_CODES)
endif()
+ if(FD_SET_CB_EXISTS)
+ target_compile_definitions(ubus_lib PUBLIC HAVE_ULOOP_FD_SET_CB)
+ endif()
endif()
if(UCI_SUPPORT)
diff --git a/lib/ubus.c b/lib/ubus.c
index 981e337..36a5674 100644
--- a/lib/ubus.c
+++ b/lib/ubus.c
@@ -665,6 +665,11 @@ uc_ubus_have_uloop(void)
bool prev = uloop_cancelled;
bool active;
+#ifdef HAVE_ULOOP_FD_SET_CB
+ if (uloop_fd_set_cb)
+ return true;
+#endif
+
uloop_cancelled = true;
active = uloop_cancelling();
uloop_cancelled = prev;