diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-08-14 23:25:34 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-08-14 23:25:34 -0700 |
| commit | e7e2a6c14f0317eb77711951c6f1a650d4013dfe (patch) | |
| tree | 7ed67e4dfbbebce4cc9d88417179c2d58fffb400 /src/nng.c | |
| parent | b47a223bfb2c7114154504ec8d6cdac5abd0b884 (diff) | |
| download | nng-e7e2a6c14f0317eb77711951c6f1a650d4013dfe.tar.gz nng-e7e2a6c14f0317eb77711951c6f1a650d4013dfe.tar.bz2 nng-e7e2a6c14f0317eb77711951c6f1a650d4013dfe.zip | |
Move socket structure to private socket implementation.
We enable a few flags, but now the details of the socket internals
are completely private to the socket.
Diffstat (limited to 'src/nng.c')
| -rw-r--r-- | src/nng.c | 27 |
1 files changed, 4 insertions, 23 deletions
@@ -132,28 +132,18 @@ nng_recv(nng_socket sid, void *buf, size_t *szp, int flags) int nng_recvmsg(nng_socket sid, nng_msg **msgp, int flags) { - nni_time expire; int rv; nni_sock *sock; if ((rv = nni_sock_find(&sock, sid)) != 0) { return (rv); } - if ((flags == NNG_FLAG_NONBLOCK) || (sock->s_rcvtimeo == 0)) { - expire = NNI_TIME_ZERO; - } else if (sock->s_rcvtimeo < 0) { - expire = NNI_TIME_NEVER; - } else { - expire = nni_clock(); - expire += sock->s_rcvtimeo; - } - - rv = nni_sock_recvmsg(sock, msgp, expire); + rv = nni_sock_recvmsg(sock, msgp, flags); nni_sock_rele(sock); // Possibly massage nonblocking attempt. Note that nonblocking is // still done asynchronously, and the calling thread loses context. - if ((rv == NNG_ETIMEDOUT) && (expire == NNI_TIME_ZERO)) { + if ((rv == NNG_ETIMEDOUT) && (flags == NNG_FLAG_NONBLOCK)) { rv = NNG_EAGAIN; } @@ -201,21 +191,12 @@ nng_sendmsg(nng_socket sid, nng_msg *msg, int flags) if ((rv = nni_sock_find(&sock, sid)) != 0) { return (rv); } - if ((flags == NNG_FLAG_NONBLOCK) || (sock->s_sndtimeo == 0)) { - expire = NNI_TIME_ZERO; - } else if (sock->s_sndtimeo < 0) { - expire = NNI_TIME_NEVER; - } else { - expire = nni_clock(); - expire += sock->s_sndtimeo; - } - - rv = nni_sock_sendmsg(sock, msg, expire); + rv = nni_sock_sendmsg(sock, msg, flags); nni_sock_rele(sock); // Possibly massage nonblocking attempt. Note that nonblocking is // still done asynchronously, and the calling thread loses context. - if ((rv == NNG_ETIMEDOUT) && (expire == NNI_TIME_ZERO)) { + if ((rv == NNG_ETIMEDOUT) && (flags == NNG_FLAG_NONBLOCK)) { rv = NNG_EAGAIN; } |
