aboutsummaryrefslogtreecommitdiff
path: root/src/platform
diff options
context:
space:
mode:
Diffstat (limited to 'src/platform')
-rw-r--r--src/platform/posix/posix_pipe.c7
-rw-r--r--src/platform/windows/win_pipe.c8
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);
}