From 45f3f141850a0ac07c31906748752571652683df Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Mon, 16 Apr 2018 11:40:28 -0700 Subject: fixes #344 nn_poll() legacy API missing This includes the test from legacy libnanomsg and a man page. We have refactored the message queue notification system so that it uses nni_pollable, leading we hope to a more consistent system, and reducing the code size and complexity. We also fixed the size of the NN_RCVFD and NN_SNDFD so that they are a SOCKET on Windows systems, rather than an integer. This addresses 64-bit compilation problems. --- src/core/pollable.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'src/core/pollable.c') diff --git a/src/core/pollable.c b/src/core/pollable.c index b5cecf37..a121ba3f 100644 --- a/src/core/pollable.c +++ b/src/core/pollable.c @@ -52,11 +52,13 @@ nni_pollable_raise(nni_pollable *p) return; } nni_mtx_lock(&p->p_lock); - p->p_raised = true; - if (p->p_open) { - nni_mtx_unlock(&p->p_lock); - nni_plat_pipe_raise(p->p_wfd); - return; + if (!p->p_raised) { + p->p_raised = true; + if (p->p_open) { + nni_mtx_unlock(&p->p_lock); + nni_plat_pipe_raise(p->p_wfd); + return; + } } nni_mtx_unlock(&p->p_lock); } @@ -68,11 +70,13 @@ nni_pollable_clear(nni_pollable *p) return; } nni_mtx_lock(&p->p_lock); - p->p_raised = false; - if (p->p_open) { - nni_mtx_unlock(&p->p_lock); - nni_plat_pipe_clear(p->p_rfd); - return; + if (p->p_raised) { + p->p_raised = false; + if (p->p_open) { + nni_mtx_unlock(&p->p_lock); + nni_plat_pipe_clear(p->p_rfd); + return; + } } nni_mtx_unlock(&p->p_lock); } -- cgit v1.2.3-70-g09d2