From 7c523eb8167116176eb43d2f9380e0179a6275b0 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Sat, 24 Feb 2024 17:14:12 +0100 Subject: irmd: Fix handling destroy during wait timeouts The object must be refreshed from the list to see if it wasn't yet destroyed if the wait times out. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/irmd/reg/reg.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) (limited to 'src/irmd') diff --git a/src/irmd/reg/reg.c b/src/irmd/reg/reg.c index 0a0a1786..d95a4722 100644 --- a/src/irmd/reg/reg.c +++ b/src/irmd/reg/reg.c @@ -1697,19 +1697,24 @@ int reg_wait_flow_allocated(struct flow_info * info, assert(false); } + flow = __reg_get_flow(flow->info.id); + if (flow == NULL) { + info->state = FLOW_DEALLOCATED; + ret = -1; + break; + } + if (ret == -ETIMEDOUT) { info->state = FLOW_DEALLOCATED; reg_flow_update(flow, info); break; } - - flow = __reg_get_flow(flow->info.id); - assert(flow != NULL); } - reg_flow_get_data(flow, pbuf); - - *info = flow->info; + if (flow != NULL) { + reg_flow_get_data(flow, pbuf); + *info = flow->info; + } pthread_cleanup_pop(true); /* __cleanup_mutex_unlock */ @@ -1849,20 +1854,26 @@ int reg_wait_flow_accepted(struct flow_info * info, assert(false); } + flow = __reg_get_flow(flow->info.id); + if (flow == NULL) { + info->state = FLOW_DEALLOCATED; + ret = -1; + break; + } + if (ret == -ETIMEDOUT) { info->state = FLOW_DEALLOCATED; reg_flow_update(flow, info); break; } - - flow = __reg_get_flow(flow->info.id); } pthread_cleanup_pop(true); /* __cleanup_wait_accept */ - reg_flow_get_data(flow, pbuf); - - *info = flow->info; + if (flow != NULL) { + reg_flow_get_data(flow, pbuf); + *info = flow->info; + } pthread_cleanup_pop(true); /* __cleanup_mutex_unlock */ @@ -2064,11 +2075,11 @@ int reg_wait_ipcp_boot(struct ipcp_info * info, continue; /* Shut up static analyzer. */ } + ipcp = __reg_get_ipcp(info->pid); + if (ret == -ETIMEDOUT) break; - - ipcp = __reg_get_ipcp(info->pid); - } + } if (ipcp != NULL) *info = ipcp->info; -- cgit v1.2.3