From 46ca4756a09d015298b310cd482f2e39d9a034db Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Thu, 26 Oct 2017 11:14:25 -0700 Subject: fixes #46 make device() use aios directly This eliminates the separate threads used for devices, letting them benefit from the new aio framework. It also eliminates the legacy nni_sock_sendmsg and nni_sock_recvmsg internal APIs. It would appear that there is an opportunity here to provide asynchronous device support out to userland as well, exposing an aio to them. That work is deferred to later. --- src/core/socket.c | 69 ------------------------------------------------------- 1 file changed, 69 deletions(-) (limited to 'src/core/socket.c') diff --git a/src/core/socket.c b/src/core/socket.c index 8fb8e67b..c9b70ccb 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -798,38 +798,6 @@ nni_sock_send(nni_sock *sock, nni_aio *aio) sock->s_sock_ops.sock_send(sock->s_data, aio); } -int -nni_sock_sendmsg(nni_sock *sock, nni_msg *msg, int flags) -{ - int rv; - nni_time expire; - nni_time timeo = sock->s_sndtimeo; - nni_aio *aio; - - if ((rv = nni_aio_init(&aio, NULL, NULL)) != 0) { - return (rv); - } - - if ((flags == NNG_FLAG_NONBLOCK) || (timeo == 0)) { - expire = NNI_TIME_ZERO; - } else if (timeo == NNI_TIME_NEVER) { - expire = NNI_TIME_NEVER; - } else { - expire = nni_clock(); - expire += timeo; - } - nni_aio_set_timeout(aio, expire); - nni_aio_set_msg(aio, msg); - - nni_sock_send(sock, aio); - nni_aio_wait(aio); - - rv = nni_aio_result(aio); - nni_aio_fini(aio); - - return (rv); -} - void nni_sock_recv(nni_sock *sock, nni_aio *aio) { @@ -837,43 +805,6 @@ nni_sock_recv(nni_sock *sock, nni_aio *aio) sock->s_sock_ops.sock_recv(sock->s_data, aio); } -int -nni_sock_recvmsg(nni_sock *sock, nni_msg **msgp, int flags) -{ - int rv; - nni_msg *msg; - nni_time expire; - nni_time timeo = sock->s_rcvtimeo; - nni_aio *aio; - - if ((rv = nni_aio_init(&aio, NULL, NULL)) != 0) { - return (rv); - } - - if ((flags == NNG_FLAG_NONBLOCK) || (timeo == 0)) { - expire = NNI_TIME_ZERO; - } else if (timeo == NNI_TIME_NEVER) { - expire = NNI_TIME_NEVER; - } else { - expire = nni_clock(); - expire += timeo; - } - - nni_aio_set_timeout(aio, expire); - nni_sock_recv(sock, aio); - nni_aio_wait(aio); - - if ((rv = nni_aio_result(aio)) == 0) { - msg = nni_aio_get_msg(aio); - nni_aio_set_msg(aio, NULL); - - *msgp = msg; - } - - nni_aio_fini(aio); - return (rv); -} - // nni_sock_protocol returns the socket's 16-bit protocol number. uint16_t nni_sock_proto(nni_sock *sock) -- cgit v1.2.3-70-g09d2