diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-07-15 15:45:48 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-07-15 15:45:48 -0700 |
| commit | 7f95fde8d752dd93c20ff0a209334f4aec549111 (patch) | |
| tree | f6226f1e9741ae855a96d215600dacb006927434 /src/core/socket.c | |
| parent | 5fe345c66139fc3242c4fdbd78bf05e5670581e8 (diff) | |
| download | nng-7f95fde8d752dd93c20ff0a209334f4aec549111.tar.gz nng-7f95fde8d752dd93c20ff0a209334f4aec549111.tar.bz2 nng-7f95fde8d752dd93c20ff0a209334f4aec549111.zip | |
Some initial progress on *connect* async.
This actually is breaking at the moment, because we don't have
good integration with timeouts, and there are some frustrating
races with timeouts at points that can cause apparent hangs.
Diffstat (limited to 'src/core/socket.c')
| -rw-r--r-- | src/core/socket.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/core/socket.c b/src/core/socket.c index 3a4f36e5..75ae8450 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -1,5 +1,6 @@ // // Copyright 2017 Garrett D'Amore <garrett@damore.org> +// Copyright 2017 Capitar IT Group BV <info@capitar.com> // // This software is supplied under the terms of the MIT License, a // copy of which should be located in the distribution where this @@ -77,6 +78,27 @@ nni_sock_rele(nni_sock *sock) } int +nni_sock_pipe_init(nni_sock *sock, nni_pipe *pipe) +{ + int rv; + + // Initialize protocol pipe data. + nni_mtx_lock(&sock->s_mx); + rv = sock->s_pipe_ops.pipe_init( + &pipe->p_proto_data, pipe, sock->s_data); + if (rv != 0) { + nni_mtx_lock(&sock->s_mx); + return (rv); + } + // Save the protocol destructor. + pipe->p_proto_dtor = sock->s_pipe_ops.pipe_fini; + pipe->p_sock = sock; + nni_list_append(&sock->s_pipes, pipe); + nni_mtx_unlock(&sock->s_mx); + return (0); +} + +int nni_sock_pipe_ready(nni_sock *sock, nni_pipe *pipe) { int rv; @@ -98,9 +120,6 @@ nni_sock_pipe_ready(nni_sock *sock, nni_pipe *pipe) return (rv); } - // We have claimed ownership of the pipe, so add it to the list. - // Up until this point, the caller could destroy the pipe. - nni_list_append(&sock->s_pipes, pipe); nni_mtx_unlock(&sock->s_mx); return (0); |
