aboutsummaryrefslogtreecommitdiff
path: root/src/core/transport.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-06-26 17:39:17 -0700
committerGarrett D'Amore <garrett@damore.org>2018-06-27 17:28:05 -0700
commit251553b13e6bc8019914b9edd1292f97e856dd43 (patch)
tree9193b8b4d4df86253f0a469cd96d8bb304a64c82 /src/core/transport.c
parent91f9061ad9289afffb0111c03a8390d0f82d7114 (diff)
downloadnng-251553b13e6bc8019914b9edd1292f97e856dd43.tar.gz
nng-251553b13e6bc8019914b9edd1292f97e856dd43.tar.bz2
nng-251553b13e6bc8019914b9edd1292f97e856dd43.zip
fixes #522 Separate out the endpoint plumbing
This separates the plumbing for endpoints into distinct dialer and listeners. Some of the transports could benefit from further separation, but we've done some rather larger separation e.g. for the websocket transport. IPC would be a good one to update later, when we start looking at exposing a more natural underlying API.
Diffstat (limited to 'src/core/transport.c')
-rw-r--r--src/core/transport.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/core/transport.c b/src/core/transport.c
index 4733b6bd..8485d048 100644
--- a/src/core/transport.c
+++ b/src/core/transport.c
@@ -118,12 +118,28 @@ 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_option *o;
+ const nni_tran_dialer_ops * dops;
+ const nni_tran_listener_ops *lops;
+ const nni_tran_option * o;
+
+ // Generally we look for endpoint options. We check both
+ // dialers and listeners.
+ dops = t->t_tran.tran_dialer;
+ 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);
+ }
- // Generally we look for endpoint options.
- ep = t->t_tran.tran_ep;
- for (o = ep->ep_options; o && o->o_name != NULL; o++) {
+ rv = (o->o_chk != NULL) ? o->o_chk(v, sz, typ) : 0;
+ nni_mtx_unlock(&nni_tran_lk);
+ return (rv);
+ }
+ lops = t->t_tran.tran_listener;
+ for (o = lops->l_options; o && o->o_name != NULL; o++) {
if (strcmp(name, o->o_name) != 0) {
continue;
}