From 249932f3a208260f6b9c99d778b22d51cfabe87b Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sun, 15 Nov 2020 17:47:54 -0800 Subject: fixes #1071 tran_chkopt can be cleaned up This is a sweeping cleanup of the transport logic around options, and also harmonizes the names used when setting or getting options. Additionally, legacy methods are now moved into a separate file and can be elided via CMake or a preprocessor define. Fundamentally, the ability to set to transport options via the socket is deprecated; there are numerous problems with this and my earlier approaches to deal with this have been somewhat misguided. Further these approaches will not work with future protocol work that is planned (were some options need to be negotiated with peers at the time of connection establishment.) Documentation has been updated to reflect this. The test suites still make rather broad use of the older APIs, and will be converted later. --- src/core/transport.c | 67 ---------------------------------------------------- 1 file changed, 67 deletions(-) (limited to 'src/core/transport.c') diff --git a/src/core/transport.c b/src/core/transport.c index 071ea0c7..78859078 100644 --- a/src/core/transport.c +++ b/src/core/transport.c @@ -111,73 +111,6 @@ nni_tran_find(nni_url *url) return (NULL); } -int -nni_tran_chkopt(const char *name, const void *v, size_t sz, int typ) -{ - nni_transport *t; - int rv = NNG_ENOTSUP; - - nni_mtx_lock(&nni_tran_lk); - NNI_LIST_FOREACH (&nni_tran_list, t) { - const nni_tran_dialer_ops * dops; - const nni_tran_listener_ops *lops; - const nni_option * o; - - // Check option entry point is cleaner than endpoint hacks. - if (t->t_tran.tran_checkopt != NULL) { - rv = t->t_tran.tran_checkopt(name, v, sz, typ); - if (rv != NNG_ENOTSUP) { - nni_mtx_unlock(&nni_tran_lk); - return (rv); - } - continue; - } - - // Generally we look for endpoint options. We check both - // dialers and listeners. - dops = t->t_tran.tran_dialer; - if ((dops->d_setopt != NULL) && - ((rv = dops->d_setopt(NULL, name, v, sz, typ)) != - NNG_ENOTSUP)) { - nni_mtx_unlock(&nni_tran_lk); - return (rv); - } - for (o = dops->d_options; o && o->o_name != NULL; o++) { - if (strcmp(name, o->o_name) != 0) { - continue; - } - if (o->o_set == NULL) { - nni_mtx_unlock(&nni_tran_lk); - return (NNG_EREADONLY); - } - nni_mtx_unlock(&nni_tran_lk); - rv = o->o_set(NULL, v, sz, typ); - return (rv); - } - lops = t->t_tran.tran_listener; - if ((lops->l_setopt != NULL) && - ((rv = lops->l_setopt(NULL, name, v, sz, typ)) != - NNG_ENOTSUP)) { - nni_mtx_unlock(&nni_tran_lk); - return (rv); - } - for (o = lops->l_options; o && o->o_name != NULL; o++) { - if (strcmp(name, o->o_name) != 0) { - continue; - } - if (o->o_set == NULL) { - nni_mtx_unlock(&nni_tran_lk); - return (NNG_EREADONLY); - } - nni_mtx_unlock(&nni_tran_lk); - rv = o->o_set(NULL, v, sz, typ); - return (rv); - } - } - nni_mtx_unlock(&nni_tran_lk); - return (rv); -} - // nni_tran_sys_init initializes the entire transport subsystem, including // each individual transport. -- cgit v1.2.3-70-g09d2