From da2aac4a6eb10af88e3938068e24c58aea1832b1 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Tue, 12 Jun 2018 20:05:34 -0700 Subject: fixes #540 nni_ep_opttype serves no purpose fixes #538 setopt should have an explicit chkopt routine fixes #537 Internal TCP API needs better name separation fixes #524 Option types should be "typed" This is a rework of the option management code, to make it both clearer and to prepare for further work to break up endpoints. This reduces a certain amount of dead or redundant code, and actually saves cycles when setting options, as some loops were not terminated that should have been. --- src/core/transport.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/core/transport.c') diff --git a/src/core/transport.c b/src/core/transport.c index 0cd84461..4733b6bd 100644 --- a/src/core/transport.c +++ b/src/core/transport.c @@ -118,23 +118,23 @@ nni_tran_chkopt(const char *name, const void *v, size_t sz, int typ) nni_mtx_lock(&nni_tran_lk); NNI_LIST_FOREACH (&nni_tran_list, t) { - const nni_tran_ep_ops * ep; - const nni_tran_ep_option *eo; + const nni_tran_ep_ops *ep; + const nni_tran_option *o; // Generally we look for endpoint options. ep = t->t_tran.tran_ep; - for (eo = ep->ep_options; eo && eo->eo_name != NULL; eo++) { - if (strcmp(name, eo->eo_name) != 0) { + for (o = ep->ep_options; o && o->o_name != NULL; o++) { + if (strcmp(name, o->o_name) != 0) { continue; } - if (eo->eo_setopt == NULL) { + if (o->o_set == NULL) { nni_mtx_unlock(&nni_tran_lk); return (NNG_EREADONLY); } - if ((rv = eo->eo_setopt(NULL, v, sz, typ)) != 0) { - nni_mtx_unlock(&nni_tran_lk); - return (rv); - } + + rv = (o->o_chk != NULL) ? o->o_chk(v, sz, typ) : 0; + nni_mtx_unlock(&nni_tran_lk); + return (rv); } } nni_mtx_unlock(&nni_tran_lk); -- cgit v1.2.3-70-g09d2