summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2024-04-25 07:38:26 -0700
committerGarrett D'Amore <garrett@damore.org>2024-05-30 07:28:48 -0700
commit3a94e22db2e9f548ff81369dd2ac2badb5b6ac0f (patch)
treec33a81a5df6f0ef2faf6f9f30d7cd756368819de /src
parente46b41a562d04ef15e73e3e729263bd60e256388 (diff)
downloadnng-3a94e22db2e9f548ff81369dd2ac2badb5b6ac0f.tar.gz
nng-3a94e22db2e9f548ff81369dd2ac2badb5b6ac0f.tar.bz2
nng-3a94e22db2e9f548ff81369dd2ac2badb5b6ac0f.zip
fixes #1827 Windows a deadlock on nng_close()
Diffstat (limited to 'src')
-rw-r--r--src/core/socket.c11
1 files changed, 2 insertions, 9 deletions
diff --git a/src/core/socket.c b/src/core/socket.c
index 44612036..ea51c06f 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -83,7 +83,6 @@ struct nni_socket {
bool s_closing; // Socket is closing
bool s_closed; // Socket closed, protected by global lock
- bool s_ctxwait; // Waiting for contexts to close.
nni_mtx s_pipe_cbs_mtx;
nni_sock_pipe_cb s_pipe_cbs[NNG_PIPE_EV_NUM];
@@ -734,7 +733,6 @@ nni_sock_shutdown(nni_sock *sock)
// a chance to do so gracefully.
while (!nni_list_empty(&sock->s_ctxs)) {
- sock->s_ctxwait = true;
nni_cv_wait(&sock->s_close_cv);
}
nni_mtx_unlock(&sock_lk);
@@ -798,7 +796,6 @@ nni_sock_close(nni_sock *s)
// Wait for all other references to drop. Note that we
// have a reference already (from our caller).
- s->s_ctxwait = true;
while ((s->s_ref > 1) || (!nni_list_empty(&s->s_ctxs))) {
nni_cv_wait(&s->s_close_cv);
}
@@ -1307,9 +1304,7 @@ nni_ctx_rele(nni_ctx *ctx)
// tries to avoid ID reuse.
nni_id_remove(&ctx_ids, ctx->c_id);
nni_list_remove(&sock->s_ctxs, ctx);
- if (sock->s_closed || sock->s_ctxwait) {
- nni_cv_wake(&sock->s_close_cv);
- }
+ nni_cv_wake(&sock->s_close_cv);
nni_mtx_unlock(&sock_lk);
nni_ctx_destroy(ctx);
@@ -1791,9 +1786,7 @@ nni_pipe_remove(nni_pipe *p)
d->d_pipe = NULL;
dialer_timer_start_locked(d); // Kick the timer to redial.
}
- if (s->s_closing) {
- nni_cv_wake(&s->s_cv);
- }
+ nni_cv_wake(&s->s_cv);
nni_mtx_unlock(&s->s_mx);
}