aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/platform.h4
-rw-r--r--src/platform/posix/posix_ipc.c4
-rw-r--r--src/platform/posix/posix_poll.c22
-rw-r--r--src/transport/ipc/ipc.c12
4 files changed, 23 insertions, 19 deletions
diff --git a/src/core/platform.h b/src/core/platform.h
index 2d83f9b7..7e6dfbbe 100644
--- a/src/core/platform.h
+++ b/src/core/platform.h
@@ -244,12 +244,12 @@ extern int nni_plat_ipc_connect(nni_plat_ipcsock *, const char *);
// nni_plat_ipc_aio_send sends data to the peer. The platform is responsible
// for attempting to send all of the data. The iov count will never be
// larger than 4. The platform may modify the iovs.
-extern void nni_plat_ipc_aio_send(nni_plat_ipcsock *, nni_aio *);
+extern void nni_plat_ipc_send(nni_plat_ipcsock *, nni_aio *);
// nni_plat_ipc_aio_recv recvs data into the buffers provided by the
// iovs. The implementation does not return until the iovs are completely
// full, or an error condition occurs.
-extern void nni_plat_ipc_aio_recv(nni_plat_ipcsock *, nni_aio *);
+extern void nni_plat_ipc_recv(nni_plat_ipcsock *, nni_aio *);
// nni_plat_seed_prng seeds the PRNG subsystem. The specified number
// of bytes of entropy should be stashed. When possible, cryptographic
diff --git a/src/platform/posix/posix_ipc.c b/src/platform/posix/posix_ipc.c
index a3d95428..c1911a05 100644
--- a/src/platform/posix/posix_ipc.c
+++ b/src/platform/posix/posix_ipc.c
@@ -54,14 +54,14 @@ nni_plat_ipc_path_resolve(nni_sockaddr *addr, const char *path)
void
-nni_plat_ipc_aio_send(nni_plat_ipcsock *s, nni_aio *aio)
+nni_plat_ipc_send(nni_plat_ipcsock *s, nni_aio *aio)
{
nni_posix_sock_aio_send((void *) s, aio);
}
void
-nni_plat_ipc_aio_recv(nni_plat_ipcsock *s, nni_aio *aio)
+nni_plat_ipc_recv(nni_plat_ipcsock *s, nni_aio *aio)
{
nni_posix_sock_aio_recv((void *) s, aio);
}
diff --git a/src/platform/posix/posix_poll.c b/src/platform/posix/posix_poll.c
index e5a2dadf..97868ff7 100644
--- a/src/platform/posix/posix_poll.c
+++ b/src/platform/posix/posix_poll.c
@@ -140,14 +140,25 @@ static void
nni_posix_epdesc_finish(nni_aio *aio, int rv, int newfd)
{
nni_posix_epdesc *ed;
+ nni_posix_pipedesc *pd;
ed = aio->a_prov_data;
+
+ // acceptq or connectq.
if (nni_list_active(&ed->connectq, aio)) {
nni_list_remove(&ed->connectq, aio);
}
+ if (rv == 0) {
+ rv = nni_posix_pipedesc_init(&pd, newfd);
+ if (rv != 0) {
+ (void) close(newfd);
+ } else {
+ aio->a_pipe = pipe;
+ }
+ }
// Abuse the count to hold our new fd. This is only for accept.
- nni_aio_finish(aio, rv, newfd);
+ nni_aio_finish(aio, rv, 0);
}
@@ -173,7 +184,7 @@ nni_posix_poll_connect(nni_posix_epdesc *ed)
switch (rv) {
case 0:
// Success!
- nni_posix_epdesc_finish(aio, 0, 0);
+ nni_posix_epdesc_finish(aio, 0, ed->fd);
continue;
case EINPROGRESS:
@@ -213,7 +224,6 @@ nni_posix_poll_accept(nni_posix_epdesc *ed)
if (newfd >= 0) {
// successful connection request!
- // We abuse the count to hold our new file descriptor.
nni_posix_epdesc_finish(aio, 0, newfd);
continue;
}
@@ -924,9 +934,6 @@ nni_posix_pipedesc_sysfini(void)
}
-// extern int nni_posix_aio_ep_init(nni_posix_aio_ep *, int);
-// extern void nni_posix_aio_ep_fini(nni_posix_aio_ep *);
-
void
nni_posix_pipedesc_recv(nni_posix_pipedesc *pd, nni_aio *aio)
{
@@ -941,9 +948,6 @@ nni_posix_pipedesc_send(nni_posix_pipedesc *pd, nni_aio *aio)
}
-// extern int nni_posix_aio_connect();
-// extern int nni_posix_aio_accept();
-
#else
// Suppress empty symbols warnings in ranlib.
diff --git a/src/transport/ipc/ipc.c b/src/transport/ipc/ipc.c
index 3f882408..3d8c4466 100644
--- a/src/transport/ipc/ipc.c
+++ b/src/transport/ipc/ipc.c
@@ -177,7 +177,7 @@ nni_ipc_pipe_nego_cb(void *arg)
aio->a_iov[0].iov_len = pipe->wanttxhead - pipe->gottxhead;
aio->a_iov[0].iov_buf = &pipe->txhead[pipe->gottxhead];
// send it down...
- nni_plat_ipc_aio_send(pipe->isp, aio);
+ nni_plat_ipc_send(pipe->isp, aio);
nni_mtx_unlock(&pipe->mtx);
return;
}
@@ -185,7 +185,7 @@ nni_ipc_pipe_nego_cb(void *arg)
aio->a_niov = 1;
aio->a_iov[0].iov_len = pipe->wantrxhead - pipe->gotrxhead;
aio->a_iov[0].iov_buf = &pipe->rxhead[pipe->gotrxhead];
- nni_plat_ipc_aio_recv(pipe->isp, aio);
+ nni_plat_ipc_recv(pipe->isp, aio);
nni_mtx_unlock(&pipe->mtx);
return;
}
@@ -310,7 +310,7 @@ nni_ipc_pipe_recv_cb(void *arg)
pipe->rxaio.a_iov[0].iov_len = nni_msg_len(pipe->rxmsg);
pipe->rxaio.a_niov = 1;
- nni_plat_ipc_aio_recv(pipe->isp, &pipe->rxaio);
+ nni_plat_ipc_recv(pipe->isp, &pipe->rxaio);
nni_mtx_unlock(&pipe->mtx);
return;
}
@@ -367,7 +367,7 @@ nni_ipc_pipe_send(void *arg, nni_aio *aio)
pipe->txaio.a_iov[2].iov_len = nni_msg_len(msg);
pipe->txaio.a_niov = 3;
- nni_plat_ipc_aio_send(pipe->isp, &pipe->txaio);
+ nni_plat_ipc_send(pipe->isp, &pipe->txaio);
nni_mtx_unlock(&pipe->mtx);
return (0);
}
@@ -407,7 +407,7 @@ nni_ipc_pipe_recv(void *arg, nni_aio *aio)
pipe->rxaio.a_iov[0].iov_len = sizeof (pipe->rxhead);
pipe->rxaio.a_niov = 1;
- nni_plat_ipc_aio_recv(pipe->isp, &pipe->rxaio);
+ nni_plat_ipc_recv(pipe->isp, &pipe->rxaio);
nni_mtx_unlock(&pipe->mtx);
return (0);
}
@@ -523,7 +523,7 @@ nni_ipc_negotiate(nni_ipc_pipe *pipe)
nni_mtx_unlock(&pipe->mtx);
return (NNG_ECLOSED);
}
- nni_plat_ipc_aio_send(pipe->isp, &pipe->negaio);
+ nni_plat_ipc_send(pipe->isp, &pipe->negaio);
nni_mtx_unlock(&pipe->mtx);
nni_aio_wait(&aio);