aboutsummaryrefslogtreecommitdiff
path: root/src/nng.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-08-14 23:25:34 -0700
committerGarrett D'Amore <garrett@damore.org>2017-08-14 23:25:34 -0700
commite7e2a6c14f0317eb77711951c6f1a650d4013dfe (patch)
tree7ed67e4dfbbebce4cc9d88417179c2d58fffb400 /src/nng.c
parentb47a223bfb2c7114154504ec8d6cdac5abd0b884 (diff)
downloadnng-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.c27
1 files changed, 4 insertions, 23 deletions
diff --git a/src/nng.c b/src/nng.c
index 015da430..822d2713 100644
--- a/src/nng.c
+++ b/src/nng.c
@@ -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;
}