diff options
| author | Garrett D'Amore <garrett@damore.org> | 2018-04-16 11:40:28 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-04-16 20:56:32 -0700 |
| commit | 45f3f141850a0ac07c31906748752571652683df (patch) | |
| tree | 0e14b8e5a72972e370f60ea5fd230a790195cd28 /src/core/pollable.c | |
| parent | e3b8f31b044e4fe7d47439467fc1622266b5335c (diff) | |
| download | nng-45f3f141850a0ac07c31906748752571652683df.tar.gz nng-45f3f141850a0ac07c31906748752571652683df.tar.bz2 nng-45f3f141850a0ac07c31906748752571652683df.zip | |
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.
Diffstat (limited to 'src/core/pollable.c')
| -rw-r--r-- | src/core/pollable.c | 24 |
1 files changed, 14 insertions, 10 deletions
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); } |
