diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-01-22 02:32:32 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-01-22 02:32:32 -0800 |
| commit | b93d5759c9b39ff153a14d474d800cd981f7dc97 (patch) | |
| tree | 1a98b7ac74cd91003c38f53ae3eb01fb8027deef /src/platform | |
| parent | 769f9a2b66aca629eb4dd240a072849a48aa300f (diff) | |
| download | nng-b93d5759c9b39ff153a14d474d800cd981f7dc97.tar.gz nng-b93d5759c9b39ff153a14d474d800cd981f7dc97.tar.bz2 nng-b93d5759c9b39ff153a14d474d800cd981f7dc97.zip | |
Event notification via pollable FDs verified working.
Diffstat (limited to 'src/platform')
| -rw-r--r-- | src/platform/posix/posix_pipe.c | 7 | ||||
| -rw-r--r-- | src/platform/windows/win_pipe.c | 8 |
2 files changed, 9 insertions, 6 deletions
diff --git a/src/platform/posix/posix_pipe.c b/src/platform/posix/posix_pipe.c index 7f6a50cc..28cd909c 100644 --- a/src/platform/posix/posix_pipe.c +++ b/src/platform/posix/posix_pipe.c @@ -84,8 +84,8 @@ nni_plat_pipe_open(int *wfd, int *rfd) if (pipe(fds) < 0) { return (nni_plat_errno(errno)); } - *wfd = fds[0]; - *rfd = fds[1]; + *wfd = fds[1]; + *rfd = fds[0]; (void) fcntl(fds[0], F_SETFD, FD_CLOEXEC); (void) fcntl(fds[1], F_SETFD, FD_CLOEXEC); @@ -101,7 +101,7 @@ nni_plat_pipe_raise(int wfd) { char c = 1; - write(wfd, &c, 1); + (void) write(wfd, &c, 1); } @@ -109,6 +109,7 @@ void nni_plat_pipe_clear(int rfd) { char buf[32]; + int rv; for (;;) { // Completely drain the pipe, but don't wait. This coalesces diff --git a/src/platform/windows/win_pipe.c b/src/platform/windows/win_pipe.c index f254d9bb..22886faa 100644 --- a/src/platform/windows/win_pipe.c +++ b/src/platform/windows/win_pipe.c @@ -9,6 +9,7 @@ #include "core/nng_impl.h" +#include <stdio.h> // Windows named pipes won't work for us; we *MUST* use sockets. This is // a real sadness, but what can you do. We use an anonymous socket bound // to localhost and a connected peer. @@ -34,19 +35,21 @@ nni_plat_pipe_open(int *wfdp, int *rfdp) // ephemeral port. addr.sin_family = AF_INET; addr.sin_port = 0; - addr.sin_addr.s_addr = INADDR_LOOPBACK; + addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); afd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (afd == INVALID_SOCKET) { goto fail; } + // Make sure we have exclusive address use... one = 1; if (setsockopt(afd, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, (char *) (&one), sizeof (one)) != 0) { goto fail; } + alen = sizeof (addr); if (bind(afd, (struct sockaddr *) &addr, alen) != 0) { goto fail; @@ -65,7 +68,6 @@ nni_plat_pipe_open(int *wfdp, int *rfdp) if (afd == INVALID_SOCKET) { goto fail; } - if (connect(rfd, (struct sockaddr *) &addr, alen) != 0) { goto fail; } @@ -105,7 +107,7 @@ fail: closesocket(wfd); } - return (0); + return (rv); } |
