diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-08-04 22:55:35 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-08-04 22:55:35 -0700 |
| commit | a40ab9c52768044fa8f8b74e43bcc23637417f7a (patch) | |
| tree | 9cb20c8bd3b486d20a44cd56799901f82829532b | |
| parent | d650139cbbddb1db52231c60473cf68e3065636a (diff) | |
| download | nng-a40ab9c52768044fa8f8b74e43bcc23637417f7a.tar.gz nng-a40ab9c52768044fa8f8b74e43bcc23637417f7a.tar.bz2 nng-a40ab9c52768044fa8f8b74e43bcc23637417f7a.zip | |
COnvert UDP to new style.
| -rw-r--r-- | CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/platform/posix/posix_udp.c | 30 |
2 files changed, 16 insertions, 16 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index c91beed4..c6d25f1b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,7 @@ if (POLICY CMP0042) cmake_policy (SET CMP0042 NEW) endif () -set(C_STANDARD 99) +set(CMAKE_C_STANDARD 99) set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) list (FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" isSystemDir) if ("${isSystemDir}" STREQUAL "-1") diff --git a/src/platform/posix/posix_udp.c b/src/platform/posix/posix_udp.c index 49e06814..db6d7af4 100644 --- a/src/platform/posix/posix_udp.c +++ b/src/platform/posix/posix_udp.c @@ -49,13 +49,10 @@ nni_posix_udp_doclose(nni_plat_udp *udp) nni_aio *aio; udp->udp_closed = 1; - while ((aio = nni_list_first(&udp->udp_recvq)) != NULL) { - nni_list_remove(&udp->udp_recvq, aio); - nni_aio_finish(aio, NNG_ECLOSED, 0); - } - while ((aio = nni_list_first(&udp->udp_sendq)) != NULL) { - nni_list_remove(&udp->udp_recvq, aio); - nni_aio_finish(aio, NNG_ECLOSED, 0); + while (((aio = nni_list_first(&udp->udp_recvq)) != NULL) || + ((aio = nni_list_first(&udp->udp_sendq)) != NULL)) { + nni_aio_list_remove(aio); + nni_aio_finish_error(aio, NNG_ECLOSED); } // Underlying socket left open until close API called. } @@ -93,7 +90,7 @@ nni_posix_udp_dorecv(nni_plat_udp *udp) return; } rv = nni_plat_errno(errno); - nni_aio_finish(aio, rv, 0); + nni_aio_finish_error(aio, rv); continue; } @@ -126,12 +123,12 @@ nni_posix_udp_dosend(nni_plat_udp *udp) if (aio->a_naddrs < 1) { // No incoming address? - nni_aio_finish(aio, NNG_EADDRINVAL, 0); + nni_aio_finish_error(aio, NNG_EADDRINVAL); return; } len = nni_posix_nn2sockaddr(&ss, &aio->a_addrs[0]); if (len < 0) { - nni_aio_finish(aio, NNG_EADDRINVAL, 0); + nni_aio_finish_error(aio, NNG_EADDRINVAL); return; } @@ -155,7 +152,7 @@ nni_posix_udp_dosend(nni_plat_udp *udp) return; } rv = nni_plat_errno(errno); - nni_aio_finish(aio, rv, 0); + nni_aio_finish_error(aio, rv); continue; } @@ -276,12 +273,15 @@ nni_plat_udp_close(nni_plat_udp *udp) } void -nni_plat_udp_cancel(nni_aio *aio) +nni_plat_udp_cancel(nni_aio *aio, int rv) { nni_plat_udp *udp = aio->a_prov_data; nni_mtx_lock(&udp->udp_mtx); - nni_aio_list_remove(aio); + if (nni_aio_list_active(aio)) { + nni_aio_list_remove(aio); + nni_aio_finish_error(aio, rv); + } nni_mtx_unlock(&udp->udp_mtx); } @@ -295,7 +295,7 @@ nni_plat_udp_recv(nni_plat_udp *udp, nni_aio *aio) } if (udp->udp_closed) { - nni_aio_finish(aio, NNG_ECLOSED, 0); + nni_aio_finish_error(aio, NNG_ECLOSED); nni_mtx_unlock(&udp->udp_mtx); return; } @@ -315,7 +315,7 @@ nni_plat_udp_send(nni_plat_udp *udp, nni_aio *aio) } if (udp->udp_closed) { - nni_aio_finish(aio, NNG_ECLOSED, 0); + nni_aio_finish_error(aio, NNG_ECLOSED); nni_mtx_unlock(&udp->udp_mtx); return; } |
