Skip to content

Commit

Permalink
inproc: use nni_refcnt
Browse files Browse the repository at this point in the history
  • Loading branch information
gdamore committed Dec 16, 2024
1 parent 26b0b11 commit 23fa7c2
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/sp/transport/inproc/inproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ struct inproc_queue {
// inproc_pair represents a pair of pipes. Because we control both
// sides of the pipes, we can allocate and free this in one structure.
struct inproc_pair {
nni_atomic_int ref;
inproc_queue queues[2];
nni_refcnt ref;
inproc_queue queues[2];
};

struct inproc_ep {
Expand Down Expand Up @@ -83,8 +83,9 @@ inproc_fini(void)
// inproc_pair destroy is called when both pipe-ends of the pipe
// have been destroyed.
static void
inproc_pair_destroy(inproc_pair *pair)
inproc_pair_destroy(void *arg)
{
inproc_pair *pair = arg;
for (int i = 0; i < 2; i++) {
nni_mtx_fini(&pair->queues[i].lock);
}
Expand Down Expand Up @@ -128,9 +129,7 @@ inproc_pipe_fini(void *arg)

if ((pair = pipe->pair) != NULL) {
// If we are the last peer, then toss the pair structure.
if (nni_atomic_dec_nv(&pair->ref) == 0) {
inproc_pair_destroy(pair);
}
nni_refcnt_rele(&pair->ref);
}

NNI_FREE_STRUCT(pipe);
Expand Down Expand Up @@ -424,8 +423,8 @@ inproc_accept_clients(inproc_ep *srv)
nni_aio_list_init(&pair->queues[i].writers);
nni_mtx_init(&pair->queues[i].lock);
}
nni_atomic_init(&pair->ref);
nni_atomic_set(&pair->ref, 2);
nni_refcnt_init(
&pair->ref, 2, pair, inproc_pair_destroy);

spipe = cpipe = NULL;
if (((rv = inproc_pipe_alloc(&cpipe, cli)) != 0) ||
Expand Down

0 comments on commit 23fa7c2

Please sign in to comment.