aboutsummaryrefslogtreecommitdiff
path: root/src/platform/posix/posix_pipedesc.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-02-15 14:08:19 -0800
committerGarrett D'Amore <garrett@damore.org>2018-02-15 14:08:19 -0800
commite7f2bd6e34fa2af9f55f200cda4bb6ceecb2ee89 (patch)
treed4b08182ebe529d36059c251176d2c1066a45ead /src/platform/posix/posix_pipedesc.c
parent45bc175ef9278c175d2fc3a0678b49b18e74c449 (diff)
downloadnng-e7f2bd6e34fa2af9f55f200cda4bb6ceecb2ee89.tar.gz
nng-e7f2bd6e34fa2af9f55f200cda4bb6ceecb2ee89.tar.bz2
nng-e7f2bd6e34fa2af9f55f200cda4bb6ceecb2ee89.zip
Simply posix pollq architecture somewhat.
This change is being made to facilitate the work done for the kqueue port. We have created two new functions, nni_posix_pollq_init and nni_posix_pollq_fini, which can be used when creating or destroying the pollq nodes. Then nodes are *added* and *removed* from the pollq structure with nni_posix_pollq_add and nni_posix_pollq_remove. The add function in particular MUST NEVER be called unless the node has a valid file descriptor.
Diffstat (limited to 'src/platform/posix/posix_pipedesc.c')
-rw-r--r--src/platform/posix/posix_pipedesc.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/platform/posix/posix_pipedesc.c b/src/platform/posix/posix_pipedesc.c
index f387c60c..7cbf534b 100644
--- a/src/platform/posix/posix_pipedesc.c
+++ b/src/platform/posix/posix_pipedesc.c
@@ -358,8 +358,8 @@ nni_posix_pipedesc_init(nni_posix_pipedesc **pdp, int fd)
nni_aio_list_init(&pd->readq);
nni_aio_list_init(&pd->writeq);
- rv = nni_posix_pollq_add(nni_posix_pollq_get(fd), &pd->node);
- if (rv != 0) {
+ if (((rv = nni_posix_pollq_init(&pd->node)) != 0) ||
+ ((rv = nni_posix_pollq_add(&pd->node)) != 0)) {
nni_mtx_fini(&pd->mtx);
NNI_FREE_STRUCT(pd);
return (rv);
@@ -373,7 +373,7 @@ nni_posix_pipedesc_fini(nni_posix_pipedesc *pd)
{
// Make sure no other polling activity is pending.
nni_posix_pipedesc_close(pd);
- nni_posix_pollq_remove(&pd->node);
+ nni_posix_pollq_fini(&pd->node);
if (pd->node.fd >= 0) {
(void) close(pd->node.fd);
}