aboutsummaryrefslogtreecommitdiff
path: root/src/protocol/survey0
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-03-18 12:46:31 -0700
committerGarrett D'Amore <garrett@damore.org>2018-03-18 12:46:31 -0700
commit8b979454d891b84da727a329906c4293fadc5f3c (patch)
treecb491c476080de11c7fc5b5868579f4ef86f4df4 /src/protocol/survey0
parent3a2af394a7d94ac5f924aaea6cbad825a9b05d75 (diff)
downloadnng-8b979454d891b84da727a329906c4293fadc5f3c.tar.gz
nng-8b979454d891b84da727a329906c4293fadc5f3c.tar.bz2
nng-8b979454d891b84da727a329906c4293fadc5f3c.zip
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.
Diffstat (limited to 'src/protocol/survey0')
-rw-r--r--src/protocol/survey0/respond.c8
-rw-r--r--src/protocol/survey0/survey.c9
2 files changed, 8 insertions, 9 deletions
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