summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2024-02-23 19:38:17 +0100
committerSander Vrijders <sander@ouroboros.rocks>2024-02-26 08:59:15 +0100
commitdc56c2211424567d9a249f3630505d92f026428e (patch)
tree70286f4e5a6f655ded6bda40fec2875cb535dfef /src
parentb65e5c1d45c8bfc38b3745cb28ac9074b1c1bdc1 (diff)
downloadouroboros-dc56c2211424567d9a249f3630505d92f026428e.tar.gz
ouroboros-dc56c2211424567d9a249f3630505d92f026428e.zip
irmd: Fix flow deallocation timeout
The timeout was set to a value calculated as abstime for a cond_wait instead of a timeout, causing flows to linger in the IPCP. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src')
-rw-r--r--src/ipcpd/local/main.c12
-rw-r--r--src/irmd/main.c11
2 files changed, 15 insertions, 8 deletions
diff --git a/src/ipcpd/local/main.c b/src/ipcpd/local/main.c
index 5a53dec5..da84e517 100644
--- a/src/ipcpd/local/main.c
+++ b/src/ipcpd/local/main.c
@@ -224,12 +224,14 @@ static int local_ipcp_flow_alloc_resp(int fd,
int out_fd;
time_t mpl = IPCP_LOCAL_MPL;
- if (ipcp_wait_flow_resp(fd) < 0)
+ if (ipcp_wait_flow_resp(fd) < 0) {
+ log_err("Failed waiting for IRMd response.");
return -1;
+ }
pthread_rwlock_wrlock(&local_data.lock);
- if (response) {
+ if (response < 0) {
if (local_data.in_out[fd] != -1)
local_data.in_out[local_data.in_out[fd]] = fd;
local_data.in_out[fd] = -1;
@@ -240,6 +242,7 @@ static int local_ipcp_flow_alloc_resp(int fd,
out_fd = local_data.in_out[fd];
if (out_fd == -1) {
pthread_rwlock_unlock(&local_data.lock);
+ log_err("Invalid out_fd.");
return -1;
}
@@ -247,8 +250,11 @@ static int local_ipcp_flow_alloc_resp(int fd,
fset_add(local_data.flows, fd);
- if (ipcp_flow_alloc_reply(out_fd, response, mpl, data) < 0)
+ if (ipcp_flow_alloc_reply(out_fd, response, mpl, data) < 0) {
+ log_err("Failed to reply to allocation");
+ fset_del(local_data.flows, fd);
return -1;
+ }
log_info("Flow allocation completed, fds (%d, %d).", out_fd, fd);
diff --git a/src/irmd/main.c b/src/irmd/main.c
index e2503d0c..ecdc2fb9 100644
--- a/src/irmd/main.c
+++ b/src/irmd/main.c
@@ -1233,17 +1233,17 @@ static int flow_alloc_reply(struct flow_info * flow,
static int flow_dealloc(struct flow_info * flow,
struct timespec * ts)
{
- log_info("Deallocating flow %d for process %d.",
- flow->id, flow->n_pid);
+ log_info("Deallocating flow %d for process %d (timeout: %zd s).",
+ flow->id, flow->n_pid, ts->tv_sec);
reg_dealloc_flow(flow);
- if (ipcp_flow_dealloc(flow->n_1_pid, flow->id, ts->tv_sec) < 0) {
+ if (ipcp_flow_dealloc(flow->n_1_pid, flow->id, ts->tv_sec) < 0) {
log_err("Failed to request dealloc from %d.", flow->n_1_pid);
return -EIPCP;
- }
+ }
- return 0;
+ return 0;
}
static int flow_dealloc_resp(struct flow_info * flow)
@@ -1462,6 +1462,7 @@ static irm_msg_t * do_command_msg(irm_msg_t * msg)
break;
case IRM_MSG_CODE__IRM_FLOW_DEALLOC:
flow = flow_info_msg_to_s(msg->flow_info);
+ ts = timespec_msg_to_s(msg->timeo);
res = flow_dealloc(&flow, &ts);
break;
case IRM_MSG_CODE__IPCP_FLOW_DEALLOC: