diff options
| author | Garrett D'Amore <garrett@damore.org> | 2025-06-22 07:17:38 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2025-06-22 07:17:38 -0700 |
| commit | 8135cbf74697b1ad9f89b134e3583088e99ecbe4 (patch) | |
| tree | b5daada2b7e9ebce20acdc08c2ad20ac65072706 | |
| parent | fb153297c987e47bde25faa113a191c16eab901a (diff) | |
| download | nng-8135cbf74697b1ad9f89b134e3583088e99ecbe4.tar.gz nng-8135cbf74697b1ad9f89b134e3583088e99ecbe4.tar.bz2 nng-8135cbf74697b1ad9f89b134e3583088e99ecbe4.zip | |
Hold the pipe across for the DTLS rx cb.
| -rw-r--r-- | src/core/pipe.c | 6 | ||||
| -rw-r--r-- | src/core/pipe.h | 4 | ||||
| -rw-r--r-- | src/sp/transport/dtls/dtls.c | 2 |
3 files changed, 12 insertions, 0 deletions
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: |
