diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-08-24 14:15:48 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-08-24 14:20:34 -0700 |
| commit | c9a68bfe6bea2acc708bf49045f6cb65017a3306 (patch) | |
| tree | e2b93b81b2962bdfb7953cb30fcfae08f0bd4093 /src/transport | |
| parent | 68ff9c823d3cead2b11a003c40c8f5affc11dc71 (diff) | |
| download | nng-c9a68bfe6bea2acc708bf49045f6cb65017a3306.tar.gz nng-c9a68bfe6bea2acc708bf49045f6cb65017a3306.tar.bz2 nng-c9a68bfe6bea2acc708bf49045f6cb65017a3306.zip | |
Eliminate legacy option settings, provide easier option IDs.
This eliminates all the old #define's or enum values, making all
option IDs now totally dynamic, and providing well-known string
values for well-behaved applications.
We have added tests of some of these options, including lookups, and
so forth. We have also fixed a few problems; including at least
one crasher bug when the timeouts on reconnect were zero.
Protocol specific options are now handled in the protocol. We will
be moving the initialization for a few of those well known entities
to the protocol startup code, following the PAIRv1 pattern, later.
Applications must therefore not depend on the value of the integer IDs,
at least until the application has opened a socket of the appropriate
type.
Diffstat (limited to 'src/transport')
| -rw-r--r-- | src/transport/inproc/inproc.c | 2 | ||||
| -rw-r--r-- | src/transport/ipc/ipc.c | 30 | ||||
| -rw-r--r-- | src/transport/tcp/tcp.c | 46 |
3 files changed, 32 insertions, 46 deletions
diff --git a/src/transport/inproc/inproc.c b/src/transport/inproc/inproc.c index 4c79ddfd..23a74998 100644 --- a/src/transport/inproc/inproc.c +++ b/src/transport/inproc/inproc.c @@ -182,6 +182,7 @@ nni_inproc_pipe_getopt(void *arg, int option, void *buf, size_t *szp) nni_inproc_pipe *pipe = arg; size_t len; +#if 0 switch (option) { case NNG_OPT_LOCALADDR: case NNG_OPT_REMOTEADDR: @@ -194,6 +195,7 @@ nni_inproc_pipe_getopt(void *arg, int option, void *buf, size_t *szp) *szp = len; return (0); } +#endif return (NNG_ENOTSUP); } diff --git a/src/transport/ipc/ipc.c b/src/transport/ipc/ipc.c index 4324eedd..e5e19f36 100644 --- a/src/transport/ipc/ipc.c +++ b/src/transport/ipc/ipc.c @@ -64,8 +64,7 @@ static void nni_ipc_ep_cb(void *); static int nni_ipc_tran_chkopt(int o, const void *data, size_t sz) { - switch (o) { - case NNG_OPT_RCVMAXSZ: + if (o == nng_optid_recvmaxsz) { return (nni_chkopt_size(data, sz, 0, NNI_MAXSZ)); } return (NNG_ENOTSUP); @@ -648,37 +647,28 @@ nni_ipc_ep_connect(void *arg, nni_aio *aio) static int nni_ipc_ep_setopt(void *arg, int opt, const void *v, size_t sz) { - int rv; + int rv = NNG_ENOTSUP; nni_ipc_ep *ep = arg; - nni_mtx_lock(&ep->mtx); - switch (opt) { - case NNG_OPT_RCVMAXSZ: + + if (opt == nng_optid_recvmaxsz) { + nni_mtx_lock(&ep->mtx); rv = nni_setopt_size(&ep->rcvmax, v, sz, 0, NNI_MAXSZ); - break; - default: - rv = NNG_ENOTSUP; - break; + nni_mtx_unlock(&ep->mtx); } - nni_mtx_unlock(&ep->mtx); return (rv); } static int nni_ipc_ep_getopt(void *arg, int opt, void *v, size_t *szp) { - int rv; + int rv = NNG_ENOTSUP; nni_ipc_ep *ep = arg; - nni_mtx_lock(&ep->mtx); - switch (opt) { - case NNG_OPT_RCVMAXSZ: + if (opt == nng_optid_recvmaxsz) { + nni_mtx_lock(&ep->mtx); rv = nni_getopt_size(&ep->rcvmax, v, szp); - break; - default: - rv = NNG_ENOTSUP; - break; + nni_mtx_unlock(&ep->mtx); } - nni_mtx_unlock(&ep->mtx); return (rv); } diff --git a/src/transport/tcp/tcp.c b/src/transport/tcp/tcp.c index f5e5ad87..de1bfa66 100644 --- a/src/transport/tcp/tcp.c +++ b/src/transport/tcp/tcp.c @@ -65,10 +65,10 @@ static void nni_tcp_ep_cb(void *arg); static int nni_tcp_tran_chkopt(int o, const void *data, size_t sz) { - switch (o) { - case NNG_OPT_RCVMAXSZ: + if (o == nng_optid_recvmaxsz) { return (nni_chkopt_size(data, sz, 0, NNI_MAXSZ)); - case NNG_OPT_LINGER: + } + if (o == nng_optid_linger) { return (nni_chkopt_usec(data, sz)); } return (NNG_ENOTSUP); @@ -766,45 +766,39 @@ nni_tcp_ep_connect(void *arg, nni_aio *aio) static int nni_tcp_ep_setopt(void *arg, int opt, const void *v, size_t sz) { - int rv; + int rv = NNG_ENOTSUP; nni_tcp_ep *ep = arg; - nni_mtx_lock(&ep->mtx); - switch (opt) { - case NNG_OPT_RCVMAXSZ: + if (opt == nng_optid_recvmaxsz) { + nni_mtx_lock(&ep->mtx); rv = nni_setopt_size(&ep->rcvmax, v, sz, 0, NNI_MAXSZ); - break; - case NNG_OPT_LINGER: + nni_mtx_unlock(&ep->mtx); + + } else if (opt == nng_optid_linger) { + nni_mtx_lock(&ep->mtx); rv = nni_setopt_usec(&ep->linger, v, sz); - break; - default: - rv = NNG_ENOTSUP; - break; + nni_mtx_unlock(&ep->mtx); } - nni_mtx_unlock(&ep->mtx); return (rv); } static int nni_tcp_ep_getopt(void *arg, int opt, void *v, size_t *szp) { - int rv; + int rv = NNG_ENOTSUP; nni_tcp_ep *ep = arg; - nni_mtx_lock(&ep->mtx); - switch (opt) { - case NNG_OPT_RCVMAXSZ: + if (opt == nng_optid_recvmaxsz) { + nni_mtx_lock(&ep->mtx); rv = nni_getopt_size(&ep->rcvmax, v, szp); - break; - case NNG_OPT_LINGER: + nni_mtx_unlock(&ep->mtx); + + } else if (opt == nng_optid_linger) { + nni_mtx_lock(&ep->mtx); rv = nni_getopt_usec(&ep->linger, v, szp); - break; - default: - // XXX: add address properties - rv = NNG_ENOTSUP; - break; + nni_mtx_unlock(&ep->mtx); } - nni_mtx_unlock(&ep->mtx); + // XXX: add address properties return (rv); } |
