diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-03-19 16:21:13 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-03-19 16:21:13 -0700 |
| commit | b8a133a9d6c5d8439c1f8ed3153d6a750aae3646 (patch) | |
| tree | 0aed9586538b1330e836501612a66074093c32e8 /src/core | |
| parent | 351ae4c98f65e5cbc71c27d6ab6410fb6228ca54 (diff) | |
| download | nng-b8a133a9d6c5d8439c1f8ed3153d6a750aae3646.tar.gz nng-b8a133a9d6c5d8439c1f8ed3153d6a750aae3646.tar.bz2 nng-b8a133a9d6c5d8439c1f8ed3153d6a750aae3646.zip | |
Eliminate p_active, better names for pipe start and stop.
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/pipe.h | 1 | ||||
| -rw-r--r-- | src/core/protocol.h | 11 | ||||
| -rw-r--r-- | src/core/socket.c | 19 |
3 files changed, 13 insertions, 18 deletions
diff --git a/src/core/pipe.h b/src/core/pipe.h index e3539e1f..55246388 100644 --- a/src/core/pipe.h +++ b/src/core/pipe.h @@ -28,7 +28,6 @@ struct nni_pipe { nni_sock * p_sock; nni_ep * p_ep; int p_reap; - int p_active; nni_mtx p_mtx; int p_refcnt; }; diff --git a/src/core/protocol.h b/src/core/protocol.h index 5f7fc4c8..745f5986 100644 --- a/src/core/protocol.h +++ b/src/core/protocol.h @@ -31,18 +31,19 @@ struct nni_proto_pipe_ops { // pipe threads have been stopped. void (*pipe_fini)(void *); - // pipe_add is called to register a pipe with the protocol. The + // pipe_start is called to register a pipe with the protocol. The // protocol can reject this, for example if another pipe is already // active on a 1:1 protocol. The protocol may not block during this, // as the socket lock is held. - int (*pipe_add)(void *); + int (*pipe_start)(void *); - // pipe_rem is called to unregister a pipe from the protocol. + // pipe_stop is called to unregister a pipe from the protocol. // Threads may still acccess data structures, so the protocol // should not free anything yet. This is called with the socket // lock held, so the protocol may not call back into the socket, and - // must not block. - void (*pipe_rem)(void *); + // must not block. This operation must be idempotent, and may + // be called even if pipe_start was not. + void (*pipe_stop)(void *); }; struct nni_proto_sock_ops { diff --git a/src/core/socket.c b/src/core/socket.c index 42de8fee..76843174 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -163,13 +163,11 @@ nni_sock_pipe_ready(nni_sock *sock, nni_pipe *pipe) return (NNG_EPROTO); } - if ((rv = sock->s_pipe_ops.pipe_add(pdata)) != 0) { + if ((rv = sock->s_pipe_ops.pipe_start(pdata)) != 0) { nni_mtx_unlock(&sock->s_mx); return (rv); } - pipe->p_active = 1; - nni_list_remove(&sock->s_idles, pipe); nni_list_append(&sock->s_pipes, pipe); @@ -193,10 +191,7 @@ nni_sock_pipe_closed(nni_sock *sock, nni_pipe *pipe) nni_list_remove(&sock->s_pipes, pipe); nni_list_append(&sock->s_idles, pipe); - if (pipe->p_active) { - pipe->p_active = 0; - sock->s_pipe_ops.pipe_rem(pdata); - } + sock->s_pipe_ops.pipe_stop(pdata); // Notify the endpoint that the pipe has closed. if (((ep = pipe->p_ep) != NULL) && ((ep->ep_pipe == pipe))) { @@ -380,7 +375,7 @@ nni_sock_nullop(void *arg) static int -nni_sock_nulladdpipe(void *arg) +nni_sock_nullstartpipe(void *arg) { NNI_ARG_UNUSED(arg); @@ -450,11 +445,11 @@ nni_sock_open(nni_sock **sockp, uint16_t pnum) } sock->s_pipe_ops = *proto->proto_pipe_ops; pops = &sock->s_pipe_ops; - if (pops->pipe_add == NULL) { - pops->pipe_add = nni_sock_nulladdpipe; + if (pops->pipe_start == NULL) { + pops->pipe_start = nni_sock_nullstartpipe; } - if (pops->pipe_rem == NULL) { - pops->pipe_rem = nni_sock_nullop; + if (pops->pipe_stop == NULL) { + pops->pipe_stop = nni_sock_nullop; } if (((rv = nni_mtx_init(&sock->s_mx)) != 0) || |
