From 8b979454d891b84da727a329906c4293fadc5f3c Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sun, 18 Mar 2018 12:46:31 -0700 Subject: fixes #295 boolean options should use C99 bool type fixes #275 nng_pipe_getopt_ptr() missing? fixes #285 nng_setopt_ptr MIS fixes #297 nng_listener/dialer_close does not validate mode This change adds some missing APIs, and changes others. In particular, certain options are now of type bool, with size of just one. This is a *breaking* change for code that uses those options -- NNG_OPT_RAW, NNG_OPT_PAIR1_POLY, NNG_OPT_TLS_VERIFIED. --- src/protocol/survey0/respond.c | 8 ++++---- src/protocol/survey0/survey.c | 9 ++++----- 2 files changed, 8 insertions(+), 9 deletions(-) (limited to 'src/protocol/survey0') diff --git a/src/protocol/survey0/respond.c b/src/protocol/survey0/respond.c index 2f0514a9..c73f5720 100644 --- a/src/protocol/survey0/respond.c +++ b/src/protocol/survey0/respond.c @@ -40,7 +40,7 @@ static void resp0_pipe_fini(void *); struct resp0_sock { nni_msgq * urq; nni_msgq * uwq; - int raw; + bool raw; int ttl; nni_idhash *pipes; char * btrace; @@ -93,7 +93,7 @@ resp0_sock_init(void **sp, nni_sock *nsock) } s->ttl = 8; // Per RFC - s->raw = 0; + s->raw = false; s->btrace = NULL; s->btrace_len = 0; s->urq = nni_sock_recvq(nsock); @@ -353,7 +353,7 @@ resp0_sock_setopt_raw(void *arg, const void *buf, size_t sz) int rv; nni_mtx_lock(&s->mtx); - rv = nni_setopt_int(&s->raw, buf, sz, 0, 1); + rv = nni_setopt_bool(&s->raw, buf, sz); nni_mtx_unlock(&s->mtx); return (rv); } @@ -362,7 +362,7 @@ static int resp0_sock_getopt_raw(void *arg, void *buf, size_t *szp) { resp0_sock *s = arg; - return (nni_getopt_int(s->raw, buf, szp)); + return (nni_getopt_bool(s->raw, buf, szp)); } static int diff --git a/src/protocol/survey0/survey.c b/src/protocol/survey0/survey.c index 637ce2e2..864287ed 100644 --- a/src/protocol/survey0/survey.c +++ b/src/protocol/survey0/survey.c @@ -39,9 +39,8 @@ static void surv0_timeout(void *); struct surv0_sock { nni_duration survtime; nni_time expire; - int raw; + bool raw; int ttl; - int closing; uint32_t nextid; // next id uint32_t survid; // outstanding request ID (big endian) nni_list pipes; @@ -93,7 +92,7 @@ surv0_sock_init(void **sp, nni_sock *nsock) nni_timer_init(&s->timer, surv0_timeout, s); s->nextid = nni_random(); - s->raw = 0; + s->raw = false; s->survtime = NNI_SECOND; s->expire = NNI_TIME_ZERO; s->uwq = nni_sock_sendq(nsock); @@ -282,7 +281,7 @@ surv0_sock_setopt_raw(void *arg, const void *buf, size_t sz) int rv; nni_mtx_lock(&s->mtx); - if ((rv = nni_setopt_int(&s->raw, buf, sz, 0, 1)) == 0) { + if ((rv = nni_setopt_bool(&s->raw, buf, sz)) == 0) { s->survid = 0; nni_timer_cancel(&s->timer); } @@ -294,7 +293,7 @@ static int surv0_sock_getopt_raw(void *arg, void *buf, size_t *szp) { surv0_sock *s = arg; - return (nni_getopt_int(s->raw, buf, szp)); + return (nni_getopt_bool(s->raw, buf, szp)); } static int -- cgit v1.2.3-70-g09d2