aboutsummaryrefslogtreecommitdiff
path: root/src/core/socket.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-01-24 19:26:31 -0800
committerGarrett D'Amore <garrett@damore.org>2017-01-24 19:42:43 -0800
commite88f07b434dbcfdb57435a14e1beadcdae3cef0d (patch)
tree79433ae3c4ed6d2501e4d63ad9ada5a621df3bd9 /src/core/socket.c
parent907a1eb392ca4b29c62b9cc3d2df1ad337695abf (diff)
downloadnng-e88f07b434dbcfdb57435a14e1beadcdae3cef0d.tar.gz
nng-e88f07b434dbcfdb57435a14e1beadcdae3cef0d.tar.bz2
nng-e88f07b434dbcfdb57435a14e1beadcdae3cef0d.zip
Add endpoint tuning of maxrcv size. Fix cmsg API.
The CMSG handling was completely borked. This is fixed now, and we stash the SP header size (ugh) in the CMSG contents to match what nanomsg does. We now pass the cmsg validation test. We also fixed handling of certain endpoint-related options, so that endpoints can get options from the socket at initialization time. This required a minor change to the transport API for endpoints. Finally, we fixed a critical fault in the REP handling of RAW sockets, which caused them to always return NNG_ESTATE in all cases. It should now honor the actual socket option.
Diffstat (limited to 'src/core/socket.c')
-rw-r--r--src/core/socket.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/core/socket.c b/src/core/socket.c
index b0ce172f..6ccf3025 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -102,9 +102,6 @@ nni_sock_hold_close(nni_sock **sockp, uint32_t id)
}
-// XXX: don't expose the upper queues to protocols, because we need to
-// trap on activity in those queues!
-
// Because we have to call back into the socket, and possibly also the proto,
// and wait for threads to terminate, we do this in a special thread. The
// assumption is that closing is always a "fast" operation.
@@ -276,6 +273,7 @@ nni_sock_open(nni_sock **sockp, uint16_t pnum)
sock->s_reconn = NNI_SECOND;
sock->s_reconnmax = 0;
sock->s_reapexit = 0;
+ sock->s_rcvmaxsz = 1024 * 1024; // 1 MB by default
NNI_LIST_INIT(&sock->s_pipes, nni_pipe, p_node);
NNI_LIST_INIT(&sock->s_reaps, nni_pipe, p_node);
NNI_LIST_INIT(&sock->s_eps, nni_ep, ep_node);
@@ -684,6 +682,20 @@ nni_sock_peer(nni_sock *sock)
}
+nni_duration
+nni_sock_linger(nni_sock *sock)
+{
+ return (sock->s_linger);
+}
+
+
+size_t
+nni_sock_rcvmaxsz(nni_sock *sock)
+{
+ return (sock->s_rcvmaxsz);
+}
+
+
int
nni_sock_dial(nni_sock *sock, const char *addr, nni_ep **epp, int flags)
{
@@ -775,6 +787,10 @@ nni_sock_setopt(nni_sock *sock, int opt, const void *val, size_t size)
case NNG_OPT_RCVBUF:
rv = nni_setopt_buf(sock->s_urq, val, size);
break;
+ case NNG_OPT_RCVMAXSZ:
+ rv = nni_setopt_size(&sock->s_rcvmaxsz, val, size, 0,
+ NNI_MAXSZ);
+ break;
}
nni_mtx_unlock(&sock->s_mx);
return (rv);
@@ -818,6 +834,9 @@ nni_sock_getopt(nni_sock *sock, int opt, void *val, size_t *sizep)
case NNG_OPT_RCVBUF:
rv = nni_getopt_buf(sock->s_urq, val, sizep);
break;
+ case NNG_OPT_RCVMAXSZ:
+ rv = nni_getopt_size(&sock->s_rcvmaxsz, val, sizep);
+ break;
case NNG_OPT_SNDFD:
rv = nni_getopt_fd(sock, &sock->s_send_fd, NNG_EV_CAN_SND,
val, sizep);