From e7f2bd6e34fa2af9f55f200cda4bb6ceecb2ee89 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Thu, 15 Feb 2018 14:08:19 -0800 Subject: 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. --- src/platform/posix/posix_udp.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/platform/posix/posix_udp.c') 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); -- cgit v1.2.3-70-g09d2