From e88f07b434dbcfdb57435a14e1beadcdae3cef0d Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Tue, 24 Jan 2017 19:26:31 -0800 Subject: 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. --- src/core/options.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src/core/options.c') diff --git a/src/core/options.c b/src/core/options.c index a0b74014..cd67e0d0 100644 --- a/src/core/options.c +++ b/src/core/options.c @@ -48,6 +48,27 @@ nni_setopt_int(int *ptr, const void *val, size_t size, int minval, int maxval) } +int +nni_setopt_size(size_t *ptr, const void *val, size_t size, size_t minval, + size_t maxval) +{ + int v; + + if (size != sizeof (v)) { + return (NNG_EINVAL); + } + memcpy(&v, val, sizeof (v)); + if (v > maxval) { + return (NNG_EINVAL); + } + if (v < minval) { + return (NNG_EINVAL); + } + *ptr = v; + return (0); +} + + int nni_getopt_duration(nni_duration *ptr, void *val, size_t *sizep) { @@ -76,6 +97,20 @@ nni_getopt_int(int *ptr, void *val, size_t *sizep) } +int +nni_getopt_size(size_t *ptr, void *val, size_t *sizep) +{ + size_t sz = sizeof (*ptr); + + if (sz > *sizep) { + sz = *sizep; + } + *sizep = sizeof (*ptr); + memcpy(val, ptr, sz); + return (0); +} + + int nni_setopt_buf(nni_msgq *mq, const void *val, size_t sz) { -- cgit v1.2.3-70-g09d2