summaryrefslogtreecommitdiff
path: root/src/transport
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/transport
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/transport')
-rw-r--r--src/transport/inproc/inproc.c6
-rw-r--r--src/transport/ipc/ipc.c12
-rw-r--r--src/transport/tcp/tcp.c14
3 files changed, 15 insertions, 17 deletions
diff --git a/src/transport/inproc/inproc.c b/src/transport/inproc/inproc.c
index d6b1ac74..66f076ea 100644
--- a/src/transport/inproc/inproc.c
+++ b/src/transport/inproc/inproc.c
@@ -189,7 +189,7 @@ nni_inproc_pipe_getopt(void *arg, int option, void *buf, size_t *szp)
static int
-nni_inproc_ep_init(void **epp, const char *url, uint16_t proto)
+nni_inproc_ep_init(void **epp, const char *url, nni_sock *sock)
{
nni_inproc_ep *ep;
int rv;
@@ -207,7 +207,7 @@ nni_inproc_ep_init(void **epp, const char *url, uint16_t proto)
ep->mode = NNI_INPROC_EP_IDLE;
ep->closed = 0;
- ep->proto = proto;
+ ep->proto = nni_sock_proto(sock);
NNI_LIST_NODE_INIT(&ep->node);
NNI_LIST_INIT(&ep->clients, nni_inproc_ep, node);
@@ -291,8 +291,6 @@ nni_inproc_ep_connect(void *arg, void **pipep)
return (NNG_ECONNREFUSED);
}
- // XXX check protocol peer validity...
-
ep->mode = NNI_INPROC_EP_DIAL;
nni_list_append(&server->clients, ep);
nni_cv_wake(&server->cv);
diff --git a/src/transport/ipc/ipc.c b/src/transport/ipc/ipc.c
index 3aef5363..4673a6dc 100644
--- a/src/transport/ipc/ipc.c
+++ b/src/transport/ipc/ipc.c
@@ -26,7 +26,7 @@ struct nni_ipc_pipe {
nni_plat_ipcsock fd;
uint16_t peer;
uint16_t proto;
- uint32_t rcvmax;
+ size_t rcvmax;
};
struct nni_ipc_ep {
@@ -34,7 +34,7 @@ struct nni_ipc_ep {
nni_plat_ipcsock fd;
int closed;
uint16_t proto;
- uint32_t rcvmax;
+ size_t rcvmax;
};
static int
@@ -123,7 +123,7 @@ nni_ipc_pipe_recv(void *arg, nni_msg **msgp)
}
NNI_GET64(buf, len);
if (len > pipe->rcvmax) {
- return (NNG_EPROTO);
+ return (NNG_EMSGSIZE);
}
if ((rv = nng_msg_alloc(&msg, (size_t) len)) != 0) {
@@ -176,7 +176,7 @@ nni_ipc_pipe_getopt(void *arg, int option, void *buf, size_t *szp)
static int
-nni_ipc_ep_init(void **epp, const char *url, uint16_t proto)
+nni_ipc_ep_init(void **epp, const char *url, nni_sock *sock)
{
nni_ipc_ep *ep;
int rv;
@@ -188,8 +188,8 @@ nni_ipc_ep_init(void **epp, const char *url, uint16_t proto)
return (NNG_ENOMEM);
}
ep->closed = 0;
- ep->proto = proto;
- ep->rcvmax = 1024 * 1024; // XXX: fix this
+ ep->proto = nni_sock_proto(sock);
+ ep->rcvmax = nni_sock_rcvmaxsz(sock);
if ((rv = nni_plat_ipc_init(&ep->fd)) != 0) {
NNI_FREE_STRUCT(ep);
return (rv);
diff --git a/src/transport/tcp/tcp.c b/src/transport/tcp/tcp.c
index d18fd289..ad2d398a 100644
--- a/src/transport/tcp/tcp.c
+++ b/src/transport/tcp/tcp.c
@@ -25,7 +25,7 @@ struct nni_tcp_pipe {
nni_plat_tcpsock fd;
uint16_t peer;
uint16_t proto;
- uint32_t rcvmax;
+ size_t rcvmax;
};
struct nni_tcp_ep {
@@ -33,7 +33,7 @@ struct nni_tcp_ep {
nni_plat_tcpsock fd;
int closed;
uint16_t proto;
- uint32_t rcvmax;
+ size_t rcvmax;
int ipv4only;
};
@@ -112,7 +112,7 @@ nni_tcp_pipe_recv(void *arg, nni_msg **msgp)
}
NNI_GET64(buf, len);
if (len > pipe->rcvmax) {
- return (NNG_EPROTO);
+ return (NNG_EMSGSIZE);
}
if ((rv = nng_msg_alloc(&msg, (size_t) len)) != 0) {
@@ -165,7 +165,7 @@ nni_tcp_pipe_getopt(void *arg, int option, void *buf, size_t *szp)
static int
-nni_tcp_ep_init(void **epp, const char *url, uint16_t proto)
+nni_tcp_ep_init(void **epp, const char *url, nni_sock *sock)
{
nni_tcp_ep *ep;
int rv;
@@ -177,9 +177,9 @@ nni_tcp_ep_init(void **epp, const char *url, uint16_t proto)
return (NNG_ENOMEM);
}
ep->closed = 0;
- ep->proto = proto;
- ep->ipv4only = 0;
- ep->rcvmax = 1024 * 1024; // XXX: fix this
+ ep->proto = nni_sock_proto(sock);
+ ep->ipv4only = 0; // XXX: FIXME
+ ep->rcvmax = nni_sock_rcvmaxsz(sock);
if ((rv = nni_plat_tcp_init(&ep->fd)) != 0) {
NNI_FREE_STRUCT(ep);