aboutsummaryrefslogtreecommitdiff
path: root/src/protocol/reqrep0
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/reqrep0
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/reqrep0')
-rw-r--r--src/protocol/reqrep0/rep.c8
-rw-r--r--src/protocol/reqrep0/req.c28
2 files changed, 18 insertions, 18 deletions
diff --git a/src/protocol/reqrep0/rep.c b/src/protocol/reqrep0/rep.c
index f1a3a409..9906de4b 100644
--- a/src/protocol/reqrep0/rep.c
+++ b/src/protocol/reqrep0/rep.c
@@ -41,7 +41,7 @@ struct rep0_sock {
nni_msgq * uwq;
nni_msgq * urq;
nni_mtx lk;
- int raw;
+ bool raw;
int ttl;
nni_idhash *pipes;
char * btrace;
@@ -92,7 +92,7 @@ rep0_sock_init(void **sp, nni_sock *sock)
}
s->ttl = 8; // Per RFC
- s->raw = 0;
+ s->raw = false;
s->btrace = NULL;
s->btrace_len = 0;
s->uwq = nni_sock_sendq(sock);
@@ -359,7 +359,7 @@ rep0_sock_setopt_raw(void *arg, const void *buf, size_t sz)
int rv;
nni_mtx_lock(&s->lk);
- rv = nni_setopt_int(&s->raw, buf, sz, 0, 1);
+ rv = nni_setopt_bool(&s->raw, buf, sz);
nni_mtx_unlock(&s->lk);
return (rv);
}
@@ -368,7 +368,7 @@ static int
rep0_sock_getopt_raw(void *arg, void *buf, size_t *szp)
{
rep0_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/reqrep0/req.c b/src/protocol/reqrep0/req.c
index 2a641933..d87a5d1f 100644
--- a/src/protocol/reqrep0/req.c
+++ b/src/protocol/reqrep0/req.c
@@ -39,9 +39,9 @@ struct req0_sock {
nni_msgq * urq;
nni_duration retry;
nni_time resend;
- int raw;
- int wantw;
- int closed;
+ bool raw;
+ bool wantw;
+ bool closed;
int ttl;
nni_msg * reqmsg;
@@ -96,8 +96,8 @@ req0_sock_init(void **sp, nni_sock *sock)
s->nextid = nni_random();
s->retry = NNI_SECOND * 60;
s->reqmsg = NULL;
- s->raw = 0;
- s->wantw = 0;
+ s->raw = false;
+ s->wantw = false;
s->resend = NNI_TIME_ZERO;
s->ttl = 8;
s->uwq = nni_sock_sendq(sock);
@@ -119,7 +119,7 @@ req0_sock_close(void *arg)
req0_sock *s = arg;
nni_mtx_lock(&s->mtx);
- s->closed = 1;
+ s->closed = true;
nni_mtx_unlock(&s->mtx);
nni_timer_cancel(&s->timer);
@@ -243,7 +243,7 @@ req0_pipe_stop(void *arg)
// schedule immediate resend.
s->pendpipe = NULL;
s->resend = NNI_TIME_ZERO;
- s->wantw = 1;
+ s->wantw = true;
req0_resend(s);
}
nni_mtx_unlock(&s->mtx);
@@ -253,14 +253,14 @@ static int
req0_sock_setopt_raw(void *arg, const void *buf, size_t sz)
{
req0_sock *s = arg;
- return (nni_setopt_int(&s->raw, buf, sz, 0, 1));
+ return (nni_setopt_bool(&s->raw, buf, sz));
}
static int
req0_sock_getopt_raw(void *arg, void *buf, size_t *szp)
{
req0_sock *s = arg;
- return (nni_getopt_int(s->raw, buf, szp));
+ return (nni_getopt_bool(s->raw, buf, szp));
}
static int
@@ -442,7 +442,7 @@ req0_timeout(void *arg)
nni_mtx_lock(&s->mtx);
if (s->reqmsg != NULL) {
- s->wantw = 1;
+ s->wantw = true;
req0_resend(s);
}
nni_mtx_unlock(&s->mtx);
@@ -467,13 +467,13 @@ req0_resend(req0_sock *s)
}
if (s->wantw) {
- s->wantw = 0;
+ s->wantw = false;
if (nni_msg_dup(&msg, s->reqmsg) != 0) {
// Failed to alloc message, reschedule it. Also,
// mark that we have a message we want to resend,
// in case something comes available.
- s->wantw = 1;
+ s->wantw = true;
nni_timer_schedule(&s->timer, nni_clock() + s->retry);
return;
}
@@ -484,7 +484,7 @@ req0_resend(req0_sock *s)
// No pipes ready to process us. Note that we have
// something to send, and schedule it.
nni_msg_free(msg);
- s->wantw = 1;
+ s->wantw = true;
return;
}
@@ -550,7 +550,7 @@ req0_sock_send(void *arg, nni_aio *aio)
s->reqmsg = msg;
// Schedule for immediate send
s->resend = NNI_TIME_ZERO;
- s->wantw = 1;
+ s->wantw = true;
req0_resend(s);