aboutsummaryrefslogtreecommitdiff
path: root/src/protocol/pubsub0/sub.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-06-12 20:05:34 -0700
committerGarrett D'Amore <garrett@damore.org>2018-06-13 18:01:52 -0700
commitda2aac4a6eb10af88e3938068e24c58aea1832b1 (patch)
treefb0676be5426ed1510945b7e7fe3d09eb45333a7 /src/protocol/pubsub0/sub.c
parent61ffae5e3649897776c26799ccaaa35d578ba816 (diff)
downloadnng-da2aac4a6eb10af88e3938068e24c58aea1832b1.tar.gz
nng-da2aac4a6eb10af88e3938068e24c58aea1832b1.tar.bz2
nng-da2aac4a6eb10af88e3938068e24c58aea1832b1.zip
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.
Diffstat (limited to 'src/protocol/pubsub0/sub.c')
-rw-r--r--src/protocol/pubsub0/sub.c26
1 files changed, 12 insertions, 14 deletions
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,
},
};