diff options
| author | Garrett D'Amore <garrett@damore.org> | 2018-07-06 14:42:53 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-07-06 18:57:29 -0700 |
| commit | 953ca274ae57f8edd12536a3dd15d134aa6e5576 (patch) | |
| tree | 7a0e889fbae7b525befefedcb5cb8f10820e7a47 /src/core/socket.h | |
| parent | 89cba92d13fbc5e059336fd054be30e50d8a2621 (diff) | |
| download | nng-953ca274ae57f8edd12536a3dd15d134aa6e5576.tar.gz nng-953ca274ae57f8edd12536a3dd15d134aa6e5576.tar.bz2 nng-953ca274ae57f8edd12536a3dd15d134aa6e5576.zip | |
fixes #568 Want a single reader/write lock on socket child objects
fixes #170 Make more use of reaper
This is a complete restructure/rethink of how child objects interact
with the socket. (This also backs out #576 as it turns out not to be
needed.) While 568 says reader/writer lock, for now we have settled
for a single writer lock. Its likely that this is sufficient.
Essentially we use the single socket lock to guard lists of the socket
children. We also use deferred deletion in the idhash to facilitate
teardown, which means endpoint closes are no longer synchronous.
We use the reaper to clean up objects when the reference count drops
to zero. We make a special exception for pipes, since they really
are not reference counted by their parents, and they are leaf objects
anyway.
We believe this addresses the main outstanding race conditions in
a much more correct and holistic way.
Note that endpoint shutdown is a little tricky, as it makes use of
atomic flags to guard against double entry, and against recursive
lock entry. This is something that would be nice to make a bit more
obvious, but what we have is safe, and the complexity is at least
confined to one place.
Diffstat (limited to 'src/core/socket.h')
| -rw-r--r-- | src/core/socket.h | 16 |
1 files changed, 0 insertions, 16 deletions
diff --git a/src/core/socket.h b/src/core/socket.h index 37256571..4b9c4642 100644 --- a/src/core/socket.h +++ b/src/core/socket.h @@ -38,20 +38,6 @@ extern void nni_sock_send(nni_sock *, nni_aio *); extern void nni_sock_recv(nni_sock *, nni_aio *); extern uint32_t nni_sock_id(nni_sock *); -// nni_sock_pipe_add adds the pipe to the socket. It is called by -// the generic pipe creation code. It also adds the socket to the -// ep list, and starts the pipe. It does all these to ensure that -// we have complete success or failure, and there is no point where -// a pipe could wind up orphaned. -extern int nni_sock_pipe_add(nni_sock *, nni_pipe *); -extern void nni_sock_pipe_remove(nni_sock *, nni_pipe *); - -extern int nni_sock_add_dialer(nni_sock *, nni_dialer *); -extern void nni_sock_remove_dialer(nni_sock *, nni_dialer *); - -extern int nni_sock_add_listener(nni_sock *, nni_listener *); -extern void nni_sock_remove_listener(nni_sock *, nni_listener *); - // These are socket methods that protocol operations can expect to call. // Note that each of these should be called without any locks held, since // the socket can reenter the protocol. @@ -76,8 +62,6 @@ extern uint32_t nni_sock_flags(nni_sock *); // should be executed. extern void nni_sock_set_pipe_cb(nni_sock *sock, int, nng_pipe_cb, void *); -extern void nni_sock_run_pipe_cb(nni_sock *sock, int, uint32_t); - extern bool nni_sock_closing(nni_sock *sock); // nni_ctx_open is used to open/create a new context structure. |
