From c9a68bfe6bea2acc708bf49045f6cb65017a3306 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Thu, 24 Aug 2017 14:15:48 -0700 Subject: Eliminate legacy option settings, provide easier option IDs. This eliminates all the old #define's or enum values, making all option IDs now totally dynamic, and providing well-known string values for well-behaved applications. We have added tests of some of these options, including lookups, and so forth. We have also fixed a few problems; including at least one crasher bug when the timeouts on reconnect were zero. Protocol specific options are now handled in the protocol. We will be moving the initialization for a few of those well known entities to the protocol startup code, following the PAIRv1 pattern, later. Applications must therefore not depend on the value of the integer IDs, at least until the application has opened a socket of the appropriate type. --- src/protocol/pubsub/pub.c | 16 ++++------------ src/protocol/pubsub/sub.c | 22 ++++++---------------- 2 files changed, 10 insertions(+), 28 deletions(-) (limited to 'src/protocol/pubsub') diff --git a/src/protocol/pubsub/pub.c b/src/protocol/pubsub/pub.c index 940f2139..bbca1ecd 100644 --- a/src/protocol/pubsub/pub.c +++ b/src/protocol/pubsub/pub.c @@ -266,14 +266,10 @@ static int nni_pub_sock_setopt(void *arg, int opt, const void *buf, size_t sz) { nni_pub_sock *pub = arg; - int rv; + int rv = NNG_ENOTSUP; - switch (opt) { - case NNG_OPT_RAW: + if (opt == nng_optid_raw) { rv = nni_setopt_int(&pub->raw, buf, sz, 0, 1); - break; - default: - rv = NNG_ENOTSUP; } return (rv); } @@ -282,14 +278,10 @@ static int nni_pub_sock_getopt(void *arg, int opt, void *buf, size_t *szp) { nni_pub_sock *pub = arg; - int rv; + int rv = NNG_ENOTSUP; - switch (opt) { - case NNG_OPT_RAW: + if (opt == nng_optid_raw) { rv = nni_getopt_int(&pub->raw, buf, szp); - break; - default: - rv = NNG_ENOTSUP; } return (rv); } diff --git a/src/protocol/pubsub/sub.c b/src/protocol/pubsub/sub.c index 78b9d157..0563b764 100644 --- a/src/protocol/pubsub/sub.c +++ b/src/protocol/pubsub/sub.c @@ -251,20 +251,14 @@ static int nni_sub_sock_setopt(void *arg, int opt, const void *buf, size_t sz) { nni_sub_sock *sub = arg; - int rv; + int rv = NNG_ENOTSUP; - switch (opt) { - case NNG_OPT_RAW: + if (opt == nng_optid_raw) { rv = nni_setopt_int(&sub->raw, buf, sz, 0, 1); - break; - case NNG_OPT_SUBSCRIBE: + } else if (opt == nng_optid_sub_subscribe) { rv = nni_sub_subscribe(sub, buf, sz); - break; - case NNG_OPT_UNSUBSCRIBE: + } else if (opt == nng_optid_sub_unsubscribe) { rv = nni_sub_unsubscribe(sub, buf, sz); - break; - default: - rv = NNG_ENOTSUP; } return (rv); } @@ -273,14 +267,10 @@ static int nni_sub_sock_getopt(void *arg, int opt, void *buf, size_t *szp) { nni_sub_sock *sub = arg; - int rv; + int rv = NNG_ENOTSUP; - switch (opt) { - case NNG_OPT_RAW: + if (opt == nng_optid_raw) { rv = nni_getopt_int(&sub->raw, buf, szp); - break; - default: - rv = NNG_ENOTSUP; } return (rv); } -- cgit v1.2.3-70-g09d2