From 8135cbf74697b1ad9f89b134e3583088e99ecbe4 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sun, 22 Jun 2025 07:17:38 -0700 Subject: Hold the pipe across for the DTLS rx cb. --- src/core/pipe.c | 6 ++++++ src/core/pipe.h | 4 ++++ src/sp/transport/dtls/dtls.c | 2 ++ 3 files changed, 12 insertions(+) (limited to 'src') diff --git a/src/core/pipe.c b/src/core/pipe.c index 5ce85420..94520c39 100644 --- a/src/core/pipe.c +++ b/src/core/pipe.c @@ -99,6 +99,12 @@ nni_pipe_rele(nni_pipe *p) nni_refcnt_rele(&p->p_refcnt); } +void +nni_pipe_hold(nni_pipe *p) +{ + nni_refcnt_hold(&p->p_refcnt); +} + // nni_pipe_id returns the 32-bit pipe id, which can be used in backtraces. uint32_t nni_pipe_id(nni_pipe *p) diff --git a/src/core/pipe.h b/src/core/pipe.h index aa7a0598..fc7b7a1a 100644 --- a/src/core/pipe.h +++ b/src/core/pipe.h @@ -55,6 +55,10 @@ extern uint32_t nni_pipe_dialer_id(nni_pipe *); // nni_pipe_rele releases the hold on the pipe placed by nni_pipe_find. extern void nni_pipe_rele(nni_pipe *); +// nni_pipe_hold adds an additional hold on the pipe. Each hold must be +// matched by a call to nni_pipe_rele. +extern void nni_pipe_hold(nni_pipe *); + // nni_pipe_add_stat adds a statistic to the pipe extern void nni_pipe_add_stat(nni_pipe *, nni_stat_item *); diff --git a/src/sp/transport/dtls/dtls.c b/src/sp/transport/dtls/dtls.c index 81c51a32..43c2a7cd 100644 --- a/src/sp/transport/dtls/dtls.c +++ b/src/sp/transport/dtls/dtls.c @@ -985,6 +985,7 @@ dtls_rx_cb(void *arg) } memcpy(nni_msg_body(msg), ep->rx_buf, nni_aio_count(aio)); dtls_start_rx(ep); + nni_pipe_hold(p->npipe); nni_mtx_unlock(&ep->mtx); nni_mtx_lock(&p->lower_mtx); @@ -1004,6 +1005,7 @@ dtls_rx_cb(void *arg) default: nni_pipe_close(p->npipe); } + nni_pipe_rele(p->npipe); return; fail: -- cgit v1.2.3-70-g09d2