diff options
| author | Garrett D'Amore <garrett@damore.org> | 2018-05-05 11:03:33 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-05-06 15:21:33 -0700 |
| commit | 916ba1ab23aa50b855fd795f095eaedb328e84d9 (patch) | |
| tree | b764e37145e7caf8f2fe7d1a3999ab6798c3a095 /src/platform | |
| parent | 7ecb0e4a74bbb3d49ebe37a14b2534a242cb930a (diff) | |
| download | nng-916ba1ab23aa50b855fd795f095eaedb328e84d9.tar.gz nng-916ba1ab23aa50b855fd795f095eaedb328e84d9.tar.bz2 nng-916ba1ab23aa50b855fd795f095eaedb328e84d9.zip | |
fixes #396 illumos doesn't build (missing NNG_PLATFORM_POSIX ON)
fixes #397 Need to cast zoneid
fixes #395 sun is predefined on illumos/Solaris
fixes #394 alloca needs to #include <alloca.h>
fixes #399 Cannot use SVR4.2 specific msghdr
fixes #402 getpeerucred needs a NULL initialized ucred
fixes #403 syntax error in posix_tcp - attempt to return void
fixes #407 illumos getegid wrong
fixes #406 nni_idhash_count is dead code
fixes #404 idhash typedef redeclared
fixes #405 warning: newline not last character in file
This is basically a slew of related bug fixes required to make this
work on illumos. Note that the fixes are not "complete", because
more work is required to support port events given that epoll is busted
on illumos.
We also fixed a bunch of things that aren't actually "bugs" per se, but
really just warnings. Silencing them makes things better for everyone.
Apparently not all compilers are equally happy with redundant (but
otherwise identical) typedefs; we use structs in some places instead of
shorter type names to silence these complaints.
Note that IPC permissions (the mode bits on the socket vnode) are not
validated on SunOS systems. This change includes documentation to reflect
that.
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. |
