From 5c9328203b277fc36550ba06720dd13e5940121b Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Sun, 10 Aug 2025 12:08:23 +0200 Subject: ipcpd: Remove old IPCP_CONN_WAIT_DIR build option The IPCP_CONN_WAIT_DIR build option is not needed anymore with the recent update to the DHT. Also cleans up some logging in the IPCP. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/ipcpd/CMakeLists.txt | 2 -- src/ipcpd/common/connmgr.c | 2 +- src/ipcpd/config.h.in | 1 - src/ipcpd/unicast/connmgr.c | 4 ---- src/ipcpd/unicast/dir/dht.c | 4 +++- src/irmd/ipcp.c | 22 ++++++++++------------ 6 files changed, 14 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/ipcpd/CMakeLists.txt b/src/ipcpd/CMakeLists.txt index 54294f11..b3b049e3 100644 --- a/src/ipcpd/CMakeLists.txt +++ b/src/ipcpd/CMakeLists.txt @@ -16,8 +16,6 @@ set(IPCP_SCHED_THR_MUL 2 CACHE STRING "Number of scheduler threads per QoS cube") set(DISABLE_CORE_LOCK TRUE CACHE BOOL "Disable locking performance threads to a core") -set(IPCP_CONN_WAIT_DIR TRUE CACHE BOOL - "Check the running state of the directory when adding a dt connection") set(DHT_ENROLL_SLACK 50 CACHE STRING "DHT enrollment waiting time (0-999, ms)") if (CMAKE_SYSTEM_NAME STREQUAL "Linux") diff --git a/src/ipcpd/common/connmgr.c b/src/ipcpd/common/connmgr.c index eed6238e..6dd5fed0 100644 --- a/src/ipcpd/common/connmgr.c +++ b/src/ipcpd/common/connmgr.c @@ -512,7 +512,7 @@ int connmgr_dealloc(enum comp_id id, case COMPID_DT: notifier_event(NOTIFY_DT_CONN_DEL, conn); break; -#if defined(BUILD_IPCP_UNICAST) && defined(IPCP_CONN_WAIT_DIR) +#if defined(BUILD_IPCP_UNICAST) case COMPID_MGMT: notifier_event(NOTIFY_MGMT_CONN_DEL, conn); break; diff --git a/src/ipcpd/config.h.in b/src/ipcpd/config.h.in index b3a118ac..d2af6440 100644 --- a/src/ipcpd/config.h.in +++ b/src/ipcpd/config.h.in @@ -51,7 +51,6 @@ #define IPCP_UNICAST_MPL @IPCP_UNICAST_MPL@ #define CONNMGR_RCV_TIMEOUT @CONNMGR_RCV_TIMEOUT@ -#cmakedefine IPCP_CONN_WAIT_DIR #cmakedefine DISABLE_CORE_LOCK #cmakedefine IPCP_FLOW_STATS #cmakedefine IPCP_DEBUG_LOCAL diff --git a/src/ipcpd/unicast/connmgr.c b/src/ipcpd/unicast/connmgr.c index 11c5d5b6..07568fb5 100644 --- a/src/ipcpd/unicast/connmgr.c +++ b/src/ipcpd/unicast/connmgr.c @@ -32,8 +32,4 @@ #define BUILD_IPCP_UNICAST -#ifdef IPCP_CONN_WAIT_DIR - #include "dir.h" -#endif - #include "common/connmgr.c" diff --git a/src/ipcpd/unicast/dir/dht.c b/src/ipcpd/unicast/dir/dht.c index 4a243059..a56c8af2 100644 --- a/src/ipcpd/unicast/dir/dht.c +++ b/src/ipcpd/unicast/dir/dht.c @@ -3693,6 +3693,8 @@ static void dht_kv_replicate(void) list_head_init(&repl); list_head_init(&rebl); + pthread_cleanup_push(free, key); + while (dht_kv_next_values(key, &repl, &rebl) == 0) { dht_kv_replicate_values(key, &repl, &rebl); if (!list_is_empty(&repl)) { @@ -3708,7 +3710,7 @@ static void dht_kv_replicate(void) } } - free(key); + pthread_cleanup_pop(true); } static void dht_kv_refresh_contacts(void) diff --git a/src/irmd/ipcp.c b/src/irmd/ipcp.c index 8a42be42..1e8980fb 100644 --- a/src/irmd/ipcp.c +++ b/src/irmd/ipcp.c @@ -85,11 +85,10 @@ ipcp_msg_t * send_recv_ipcp_msg(pid_t pid, uint8_t buf[SOCK_BUF_SIZE]; char * spath; ssize_t len; - ipcp_msg_t * recv_msg; struct timeval tv; struct timespec tic; struct timespec toc; - bool dealloc = false; + bool may_fail = false; if (kill(pid, 0) < 0) return NULL; @@ -127,6 +126,7 @@ ipcp_msg_t * send_recv_ipcp_msg(pid_t pid, tv.tv_usec = (REG_TIMEOUT % 1000) * 1000; break; case IPCP_MSG_CODE__IPCP_QUERY: + may_fail = true; /* name not always in Layer */ tv.tv_sec = QUERY_TIMEOUT / 1000; tv.tv_usec = (QUERY_TIMEOUT % 1000) * 1000; break; @@ -139,7 +139,7 @@ ipcp_msg_t * send_recv_ipcp_msg(pid_t pid, tv.tv_usec = (FLOW_ALLOC_TIMEOUT % 1000) * 1000; break; case IPCP_MSG_CODE__IPCP_FLOW_DEALLOC: - dealloc = true; + may_fail = true; tv.tv_sec = 0; /* FIX DEALLOC: don't wait for dealloc */ tv.tv_usec = 500; break; @@ -167,17 +167,15 @@ ipcp_msg_t * send_recv_ipcp_msg(pid_t pid, pthread_cleanup_pop(true); /* close socket */ if (len > 0) - recv_msg = ipcp_msg__unpack(NULL, len, buf); - else { - if (errno == EAGAIN && !dealloc) { - int diff = ts_diff_ms(&toc, &tic); - log_warn("IPCP %s timed out after %d ms.", - str_ipcp_cmd(msg->code), diff); - } - return NULL; + return ipcp_msg__unpack(NULL, len, buf); + + if (errno == EAGAIN && !may_fail) { + int diff = ts_diff_ms(&toc, &tic); + log_warn("IPCP %s timed out after %d ms.", + str_ipcp_cmd(msg->code), diff); } - return recv_msg; + return NULL; } int ipcp_bootstrap(pid_t pid, -- cgit v1.2.3