diff options
Diffstat (limited to 'src/platform')
| -rw-r--r-- | src/platform/posix/posix_aio.h | 2 | ||||
| -rw-r--r-- | src/platform/posix/posix_epdesc.c | 4 | ||||
| -rw-r--r-- | src/platform/posix/posix_pipedesc.c | 7 | ||||
| -rw-r--r-- | src/platform/posix/posix_tcp.c | 4 | ||||
| -rw-r--r-- | src/platform/posix/posix_udp.c | 46 |
5 files changed, 31 insertions, 32 deletions
diff --git a/src/platform/posix/posix_aio.h b/src/platform/posix/posix_aio.h index 7d6a7231..15d91db2 100644 --- a/src/platform/posix/posix_aio.h +++ b/src/platform/posix/posix_aio.h @@ -19,8 +19,6 @@ #include "core/nng_impl.h" -typedef struct nni_posix_pollq nni_posix_pollq; - typedef struct nni_posix_pipedesc nni_posix_pipedesc; typedef struct nni_posix_epdesc nni_posix_epdesc; diff --git a/src/platform/posix/posix_epdesc.c b/src/platform/posix/posix_epdesc.c index 0f63304f..7431dedf 100644 --- a/src/platform/posix/posix_epdesc.c +++ b/src/platform/posix/posix_epdesc.c @@ -28,6 +28,10 @@ #include <sys/un.h> #include <unistd.h> +#ifdef sun +#undef sun +#endif + #ifdef SOCK_CLOEXEC #define NNI_STREAM_SOCKTYPE (SOCK_STREAM | SOCK_CLOEXEC) #else diff --git a/src/platform/posix/posix_pipedesc.c b/src/platform/posix/posix_pipedesc.c index 61005ca8..3745f11f 100644 --- a/src/platform/posix/posix_pipedesc.c +++ b/src/platform/posix/posix_pipedesc.c @@ -32,6 +32,9 @@ #include <sys/ucred.h> #include <sys/un.h> #endif +#ifdef NNG_HAVE_ALLOCA +#include <alloca.h> +#endif // nni_posix_pipedesc is a descriptor kept one per transport pipe (i.e. open // file descriptor for TCP socket, etc.) This contains the list of pending @@ -426,12 +429,12 @@ nni_posix_pipedesc_get_peerid(nni_posix_pipedesc *pd, uint64_t *euid, *znid = (uint64_t) -1; return (0); #elif defined(NNG_HAVE_GETPEERUCRED) - ucred *ucp; + ucred_t *ucp = NULL; if (getpeerucred(fd, &ucp) != 0) { return (nni_plat_errno(errno)); } *euid = ucred_geteuid(ucp); - *egid = ucred_geteuid(ucp); + *egid = ucred_getegid(ucp); *prid = ucred_getpid(ucp); *znid = ucred_getzoneid(ucp); ucred_free(ucp); diff --git a/src/platform/posix/posix_tcp.c b/src/platform/posix/posix_tcp.c index c00f9433..ace1f6bd 100644 --- a/src/platform/posix/posix_tcp.c +++ b/src/platform/posix/posix_tcp.c @@ -79,13 +79,13 @@ nni_plat_tcp_ep_listen(nni_plat_tcp_ep *ep, nng_sockaddr *bsa) void nni_plat_tcp_ep_connect(nni_plat_tcp_ep *ep, nni_aio *aio) { - return (nni_posix_epdesc_connect((void *) ep, aio)); + nni_posix_epdesc_connect((void *) ep, aio); } void nni_plat_tcp_ep_accept(nni_plat_tcp_ep *ep, nni_aio *aio) { - return (nni_posix_epdesc_accept((void *) ep, aio)); + nni_posix_epdesc_accept((void *) ep, aio); } void diff --git a/src/platform/posix/posix_udp.c b/src/platform/posix/posix_udp.c index 37f79431..654d31e3 100644 --- a/src/platform/posix/posix_udp.c +++ b/src/platform/posix/posix_udp.c @@ -24,14 +24,15 @@ #include <sys/types.h> #include <sys/uio.h> #include <unistd.h> +#ifdef NNG_HAVE_ALLOCA +#include <alloca.h> +#endif // UDP support. // If we can suppress SIGPIPE on send, please do so. -#ifdef MSG_NOSIGNAL -#define NNI_MSG_NOSIGNAL MSG_NOSIGNAL -#else -#define NNI_MSG_NOSIGNAL 0 +#ifndef MSG_NOSIGNAL +#define MSG_NOSIGNAL 0 #endif struct nni_plat_udp { @@ -67,7 +68,7 @@ nni_posix_udp_dorecv(nni_plat_udp *udp) nni_iov * aiov; struct sockaddr_storage ss; nng_sockaddr * sa; - struct msghdr hdr; + struct msghdr hdr = { .msg_name = NULL }; int rv = 0; int cnt = 0; @@ -77,13 +78,10 @@ nni_posix_udp_dorecv(nni_plat_udp *udp) iov[i].iov_base = aiov[i].iov_buf; iov[i].iov_len = aiov[i].iov_len; } - hdr.msg_iov = iov; - hdr.msg_iovlen = niov; - hdr.msg_name = &ss; - hdr.msg_namelen = sizeof(ss); - hdr.msg_flags = 0; - hdr.msg_control = NULL; - hdr.msg_controllen = 0; + hdr.msg_iov = iov; + hdr.msg_iovlen = niov; + hdr.msg_name = &ss; + hdr.msg_namelen = sizeof(ss); if ((cnt = recvmsg(udp->udp_fd, &hdr, 0)) < 0) { if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) { @@ -121,9 +119,8 @@ nni_posix_udp_dosend(nni_plat_udp *udp) if (len < 1) { rv = NNG_EADDRINVAL; } else { - struct msghdr hdr; - unsigned niov; - nni_iov * aiov; + unsigned niov; + nni_iov *aiov; #ifdef NNG_HAVE_ALLOCA struct iovec *iov; #else @@ -142,22 +139,19 @@ nni_posix_udp_dosend(nni_plat_udp *udp) rv = NNG_EINVAL; } #endif - if (rv == 0) { + struct msghdr hdr = { .msg_name = NULL }; for (unsigned i = 0; i < niov; i++) { iov[i].iov_base = aiov[i].iov_buf; iov[i].iov_len = aiov[i].iov_len; } - hdr.msg_iov = iov; - hdr.msg_iovlen = niov; - hdr.msg_name = &ss; - hdr.msg_namelen = len; - hdr.msg_flags = NNI_MSG_NOSIGNAL; - hdr.msg_control = NULL; - hdr.msg_controllen = 0; - - if ((cnt = sendmsg(udp->udp_fd, &hdr, 0)) < - 0) { + hdr.msg_iov = iov; + hdr.msg_iovlen = niov; + hdr.msg_name = &ss; + hdr.msg_namelen = len; + + cnt = sendmsg(udp->udp_fd, &hdr, MSG_NOSIGNAL); + if (cnt < 0) { if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) { // Cannot send now, leave. |
