aboutsummaryrefslogtreecommitdiff
path: root/src/platform/posix/posix_udp.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_udp.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_udp.c')
-rw-r--r--src/platform/posix/posix_udp.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/platform/posix/posix_udp.c b/src/platform/posix/posix_udp.c
index cde58e7c..61546667 100644
--- a/src/platform/posix/posix_udp.c
+++ b/src/platform/posix/posix_udp.c
@@ -244,9 +244,8 @@ nni_plat_udp_open(nni_plat_udp **upp, nni_sockaddr *bindaddr)
nni_aio_list_init(&udp->udp_recvq);
nni_aio_list_init(&udp->udp_sendq);
- rv = nni_posix_pollq_add(
- nni_posix_pollq_get(udp->udp_fd), &udp->udp_pitem);
- if (rv != 0) {
+ if (((rv = nni_posix_pollq_init(&udp->udp_pitem)) != 0) ||
+ ((rv = nni_posix_pollq_add(&udp->udp_pitem)) != 0)) {
(void) close(udp->udp_fd);
nni_mtx_fini(&udp->udp_mtx);
NNI_FREE_STRUCT(udp);
@@ -261,7 +260,7 @@ void
nni_plat_udp_close(nni_plat_udp *udp)
{
// We're no longer interested in events.
- nni_posix_pollq_remove(&udp->udp_pitem);
+ nni_posix_pollq_fini(&udp->udp_pitem);
nni_mtx_lock(&udp->udp_mtx);
nni_posix_udp_doclose(udp);