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/protocol/pubsub0/pub.c | 4 ++-- src/protocol/pubsub0/sub.c | 26 ++++++++++++-------------- 2 files changed, 14 insertions(+), 16 deletions(-) (limited to 'src/protocol/pubsub0') diff --git a/src/protocol/pubsub0/pub.c b/src/protocol/pubsub0/pub.c index 4db48754..72cd1daa 100644 --- a/src/protocol/pubsub0/pub.c +++ b/src/protocol/pubsub0/pub.c @@ -304,10 +304,10 @@ static nni_proto_pipe_ops pub0_pipe_ops = { .pipe_stop = pub0_pipe_stop, }; -static nni_proto_sock_option pub0_sock_options[] = { +static nni_proto_option pub0_sock_options[] = { // terminate list { - .pso_name = NULL, + .o_name = NULL, }, }; diff --git a/src/protocol/pubsub0/sub.c b/src/protocol/pubsub0/sub.c index a7d6b9f5..2e8be4be 100644 --- a/src/protocol/pubsub0/sub.c +++ b/src/protocol/pubsub0/sub.c @@ -194,12 +194,12 @@ sub0_recv_cb(void *arg) // to replace this with a patricia trie, like old nanomsg had. static int -sub0_subscribe(void *arg, const void *buf, size_t sz, int typ) +sub0_subscribe(void *arg, const void *buf, size_t sz, nni_opt_type t) { sub0_sock * s = arg; sub0_topic *topic; sub0_topic *newtopic; - NNI_ARG_UNUSED(typ); + NNI_ARG_UNUSED(t); nni_mtx_lock(&s->lk); NNI_LIST_FOREACH (&s->topics, topic) { @@ -245,12 +245,12 @@ sub0_subscribe(void *arg, const void *buf, size_t sz, int typ) } static int -sub0_unsubscribe(void *arg, const void *buf, size_t sz, int typ) +sub0_unsubscribe(void *arg, const void *buf, size_t sz, nni_opt_type t) { sub0_sock * s = arg; sub0_topic *topic; int rv; - NNI_ARG_UNUSED(typ); + NNI_ARG_UNUSED(t); nni_mtx_lock(&s->lk); NNI_LIST_FOREACH (&s->topics, topic) { @@ -348,22 +348,20 @@ static nni_proto_pipe_ops sub0_pipe_ops = { .pipe_stop = sub0_pipe_stop, }; -static nni_proto_sock_option sub0_sock_options[] = { +static nni_proto_option sub0_sock_options[] = { { - .pso_name = NNG_OPT_SUB_SUBSCRIBE, - .pso_type = NNI_TYPE_OPAQUE, - .pso_getopt = NULL, - .pso_setopt = sub0_subscribe, + .o_name = NNG_OPT_SUB_SUBSCRIBE, + .o_type = NNI_TYPE_OPAQUE, + .o_set = sub0_subscribe, }, { - .pso_name = NNG_OPT_SUB_UNSUBSCRIBE, - .pso_type = NNI_TYPE_OPAQUE, - .pso_getopt = NULL, - .pso_setopt = sub0_unsubscribe, + .o_name = NNG_OPT_SUB_UNSUBSCRIBE, + .o_type = NNI_TYPE_OPAQUE, + .o_set = sub0_unsubscribe, }, // terminate list { - .pso_name = NULL, + .o_name = NULL, }, }; -- cgit v1.2.3-70-g09d2