aboutsummaryrefslogtreecommitdiff
path: root/src/platform/posix
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-06-29 11:33:01 -0700
committerGarrett D'Amore <garrett@damore.org>2017-06-29 11:33:01 -0700
commit36bd0c71ce7a0bfbb22ffc99aa0dd94ed95cfc64 (patch)
treea2ab064810f269fac8e9b0473685a02c5643f5c9 /src/platform/posix
parentd0c0c9969ab5552889f91d09db6dbf6b79f6705c (diff)
downloadnng-36bd0c71ce7a0bfbb22ffc99aa0dd94ed95cfc64.tar.gz
nng-36bd0c71ce7a0bfbb22ffc99aa0dd94ed95cfc64.tar.bz2
nng-36bd0c71ce7a0bfbb22ffc99aa0dd94ed95cfc64.zip
Pass cancel of IPC and TCP all the way down to POSIX pipedescs.
Diffstat (limited to 'src/platform/posix')
-rw-r--r--src/platform/posix/posix_aio.h4
-rw-r--r--src/platform/posix/posix_ipc.c8
-rw-r--r--src/platform/posix/posix_net.c8
-rw-r--r--src/platform/posix/posix_poll.c22
4 files changed, 21 insertions, 21 deletions
diff --git a/src/platform/posix/posix_aio.h b/src/platform/posix/posix_aio.h
index de662ff2..e762bebe 100644
--- a/src/platform/posix/posix_aio.h
+++ b/src/platform/posix/posix_aio.h
@@ -24,8 +24,8 @@ extern int nni_posix_pipedesc_sysinit(void);
extern void nni_posix_pipedesc_sysfini(void);
extern int nni_posix_pipedesc_init(nni_posix_pipedesc **, int);
extern void nni_posix_pipedesc_fini(nni_posix_pipedesc *);
-extern int nni_posix_pipedesc_read(nni_posix_pipedesc *, nni_aio *);
-extern int nni_posix_pipedesc_write(nni_posix_pipedesc *, nni_aio *);
+extern void nni_posix_pipedesc_read(nni_posix_pipedesc *, nni_aio *);
+extern void nni_posix_pipedesc_write(nni_posix_pipedesc *, nni_aio *);
extern void nni_posix_pipedesc_close(nni_posix_pipedesc *);
#endif // PLATFORM_POSIX_AIO_H
diff --git a/src/platform/posix/posix_ipc.c b/src/platform/posix/posix_ipc.c
index ba46b41e..44307ca5 100644
--- a/src/platform/posix/posix_ipc.c
+++ b/src/platform/posix/posix_ipc.c
@@ -66,17 +66,17 @@ nni_plat_ipc_path_to_sockaddr(struct sockaddr_un *sun, const char *path)
}
-int
+void
nni_plat_ipc_aio_send(nni_plat_ipcsock *isp, nni_aio *aio)
{
- return (nni_posix_pipedesc_write(isp->pd, aio));
+ nni_posix_pipedesc_write(isp->pd, aio);
}
-int
+void
nni_plat_ipc_aio_recv(nni_plat_ipcsock *isp, nni_aio *aio)
{
- return (nni_posix_pipedesc_read(isp->pd, aio));
+ nni_posix_pipedesc_read(isp->pd, aio);
}
diff --git a/src/platform/posix/posix_net.c b/src/platform/posix/posix_net.c
index 5ae9904a..1d44435e 100644
--- a/src/platform/posix/posix_net.c
+++ b/src/platform/posix/posix_net.c
@@ -170,17 +170,17 @@ nni_plat_tcp_send(nni_plat_tcpsock *s, nni_iov *iovs, int cnt)
}
-int
+void
nni_plat_tcp_aio_send(nni_plat_tcpsock *s, nni_aio *aio)
{
- return (nni_posix_pipedesc_write(s->pd, aio));
+ nni_posix_pipedesc_write(s->pd, aio);
}
-int
+void
nni_plat_tcp_aio_recv(nni_plat_tcpsock *s, nni_aio *aio)
{
- return (nni_posix_pipedesc_read(s->pd, aio));
+ nni_posix_pipedesc_read(s->pd, aio);
}
diff --git a/src/platform/posix/posix_poll.c b/src/platform/posix/posix_poll.c
index 7fb07917..a30c0953 100644
--- a/src/platform/posix/posix_poll.c
+++ b/src/platform/posix/posix_poll.c
@@ -42,6 +42,7 @@ struct nni_posix_pipedesc {
nni_list writeq;
nni_list_node node;
nni_posix_pollq * pq;
+ int nonblocking;
};
// nni_posix_pollq is a work structure used by the poller thread, that keeps
@@ -417,14 +418,17 @@ nni_posix_pipedesc_submit(nni_posix_pipedesc *pd, nni_list *l, nni_aio *aio)
int rv;
nni_posix_pollq *pq = pd->pq;
- // XXX: this should be done only once, after tcp negot. is done
- // or at init if we can get tcp negot. to be async.
- (void) fcntl(pd->fd, F_SETFL, O_NONBLOCK);
-
nni_mtx_lock(&pq->mtx);
if (pd->fd < 0) {
nni_mtx_unlock(&pq->mtx);
nni_aio_finish(aio, NNG_ECLOSED, aio->a_count);
+ return;
+ }
+ // XXX: We really should just make all the FDs nonblocking, but we
+ // need to fix the negotiation phase.
+ if (pd->nonblocking == 0) {
+ (void) fcntl(pd->fd, F_SETFL, O_NONBLOCK);
+ pd->nonblocking = 1;
}
if ((rv = nni_aio_start(aio, nni_posix_pipedesc_cancel, pd)) != 0) {
nni_mtx_unlock(&pq->mtx);
@@ -470,6 +474,7 @@ nni_posix_pipedesc_init(nni_posix_pipedesc **pdp, int fd)
pd->pq = &nni_posix_global_pollq;
pd->fd = fd;
pd->index = 0;
+ pd->nonblocking = 0;
NNI_LIST_INIT(&pd->readq, nni_aio, a_prov_node);
NNI_LIST_INIT(&pd->writeq, nni_aio, a_prov_node);
@@ -567,22 +572,17 @@ 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 *);
-int
+void
nni_posix_pipedesc_read(nni_posix_pipedesc *pd, nni_aio *aio)
{
- aio->a_count = 0;
-
nni_posix_pipedesc_submit(pd, &pd->readq, aio);
- return (0);
}
-int
+void
nni_posix_pipedesc_write(nni_posix_pipedesc *pd, nni_aio *aio)
{
- aio->a_count = 0;
nni_posix_pipedesc_submit(pd, &pd->writeq, aio);
- return (0);
}