diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-06-28 23:07:28 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-06-28 23:07:28 -0700 |
| commit | fe3c9705072ac8cafecdf2ea6bca4c26f9464824 (patch) | |
| tree | 07aaea70cbf8bb6af369d5efede475ed03ffdd63 /src/core/endpt.c | |
| parent | 10d748fa6444324878a77cc5749c93b75819ced2 (diff) | |
| download | nng-fe3c9705072ac8cafecdf2ea6bca4c26f9464824.tar.gz nng-fe3c9705072ac8cafecdf2ea6bca4c26f9464824.tar.bz2 nng-fe3c9705072ac8cafecdf2ea6bca4c26f9464824.zip | |
Refactor stop again, closing numerous races (thanks valgrind!)
Diffstat (limited to 'src/core/endpt.c')
| -rw-r--r-- | src/core/endpt.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/core/endpt.c b/src/core/endpt.c index 74bd0314..e3f78ecd 100644 --- a/src/core/endpt.c +++ b/src/core/endpt.c @@ -203,14 +203,7 @@ nni_ep_stop(nni_ep *ep) void nni_ep_close(nni_ep *ep) { - nni_pipe *pipe; - nni_ep_stop(ep); - nni_mtx_lock(&ep->ep_mtx); - NNI_LIST_FOREACH (&ep->ep_pipes, pipe) { - nni_pipe_close(pipe); - } - nni_mtx_unlock(&ep->ep_mtx); } @@ -220,7 +213,15 @@ nni_ep_remove(nni_ep *ep) nni_pipe *pipe; nni_sock *sock = ep->ep_sock; - nni_ep_close(ep); + nni_ep_stop(ep); + + nni_thr_wait(&ep->ep_thr); + + nni_mtx_lock(&ep->ep_mtx); + NNI_LIST_FOREACH (&ep->ep_pipes, pipe) { + nni_pipe_close(pipe); + } + nni_mtx_unlock(&ep->ep_mtx); nni_mtx_lock(&ep->ep_mtx); while (nni_list_first(&ep->ep_pipes) != NULL) { |
