summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2024-02-24 17:14:12 +0100
committerSander Vrijders <sander@ouroboros.rocks>2024-02-26 08:59:15 +0100
commit7c523eb8167116176eb43d2f9380e0179a6275b0 (patch)
tree29de7676e8de05ea7a30d7d9d140e7f48a32cd53 /src
parent12c3298335c48fcdd1551c1474f9afe07e9a067f (diff)
downloadouroboros-7c523eb8167116176eb43d2f9380e0179a6275b0.tar.gz
ouroboros-7c523eb8167116176eb43d2f9380e0179a6275b0.zip
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 <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src')
-rw-r--r--src/irmd/reg/reg.c39
1 files changed, 25 insertions, 14 deletions
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;