Skip to content

Commit

Permalink
Merge pull request #198 from nbd168/ubus-uloop-fix
Browse files Browse the repository at this point in the history
ubus: fix uc_ubus_have_uloop for eloop+uloop combination
  • Loading branch information
jow- authored May 2, 2024
2 parents 69dd962 + f211d5a commit 25d41ba
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,21 @@ 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; }
")
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)
Expand Down
5 changes: 5 additions & 0 deletions lib/ubus.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 25d41ba

Please sign in to comment.