summaryrefslogtreecommitdiff
path: root/src/irmd
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2024-02-23 10:33:51 +0100
committerSander Vrijders <sander@ouroboros.rocks>2024-02-23 16:41:37 +0100
commit183208fd113646acbf08973e16ab9224f3f86179 (patch)
tree3cdaa836e928744ec67a84563ca513fa5e89d4fd /src/irmd
parente6c2d4c9c6b8b12bbcf7bc8bd494b3ba56133e1f (diff)
downloadouroboros-183208fd113646acbf08973e16ab9224f3f86179.tar.gz
ouroboros-183208fd113646acbf08973e16ab9224f3f86179.zip
irmd: Fix race between alloc timeout and respond
If a flow allocation times out just before the response, there is a short window where the response will still find the flow, but in DEALLOCATED state. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/irmd')
-rw-r--r--src/irmd/reg/reg.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/irmd/reg/reg.c b/src/irmd/reg/reg.c
index 731e44b6..87641f1a 100644
--- a/src/irmd/reg/reg.c
+++ b/src/irmd/reg/reg.c
@@ -1788,7 +1788,12 @@ int reg_respond_alloc(struct flow_info * info,
flow = __reg_get_flow(info->id);
if (flow == NULL) {
- log_err("Flow not found for allocation: %d", info->id);
+ log_warn("Flow %d already destroyed.", info->id);
+ goto fail_flow;
+ }
+
+ if (flow->info.state == FLOW_DEALLOCATED) {
+ log_warn("Flow %d already deallocated.", info->id);
goto fail_flow;
}
@@ -2090,7 +2095,6 @@ int reg_wait_ipcp_boot(struct ipcp_info * info,
ipcp = __reg_get_ipcp(info->pid);
- /* Potential race with the reg_respond_flow. */
if (ipcp->info.state == IPCP_INIT)
reg_ipcp_update(ipcp, info);