diff options
Diffstat (limited to 'src/protocol')
| -rw-r--r-- | src/protocol/bus0/bus.c | 9 | ||||
| -rw-r--r-- | src/protocol/pair0/pair.c | 8 | ||||
| -rw-r--r-- | src/protocol/pair1/pair.c | 24 | ||||
| -rw-r--r-- | src/protocol/pipeline0/pull.c | 8 | ||||
| -rw-r--r-- | src/protocol/pipeline0/push.c | 8 | ||||
| -rw-r--r-- | src/protocol/pubsub0/pub.c | 8 | ||||
| -rw-r--r-- | src/protocol/pubsub0/sub.c | 8 | ||||
| -rw-r--r-- | src/protocol/reqrep0/rep.c | 8 | ||||
| -rw-r--r-- | src/protocol/reqrep0/req.c | 28 | ||||
| -rw-r--r-- | src/protocol/survey0/respond.c | 8 | ||||
| -rw-r--r-- | src/protocol/survey0/survey.c | 9 |
11 files changed, 63 insertions, 63 deletions
diff --git a/src/protocol/bus0/bus.c b/src/protocol/bus0/bus.c index 1176bf01..d2b51cd4 100644 --- a/src/protocol/bus0/bus.c +++ b/src/protocol/bus0/bus.c @@ -8,6 +8,7 @@ // found online at https://opensource.org/licenses/MIT. // +#include <stdbool.h> #include <stdlib.h> #include <string.h> @@ -41,7 +42,7 @@ static void bus0_pipe_putq_cb(void *); // bus0_sock is our per-socket protocol private structure. struct bus0_sock { - int raw; + bool raw; nni_aio * aio_getq; nni_list pipes; nni_mtx mtx; @@ -88,7 +89,7 @@ bus0_sock_init(void **sp, nni_sock *nsock) bus0_sock_fini(s); return (rv); } - s->raw = 0; + s->raw = false; s->uwq = nni_sock_sendq(nsock); s->urq = nni_sock_recvq(nsock); @@ -336,14 +337,14 @@ static int bus0_sock_setopt_raw(void *arg, const void *buf, size_t sz) { bus0_sock *s = arg; - return (nni_setopt_int(&s->raw, buf, sz, 0, 1)); + return (nni_setopt_bool(&s->raw, buf, sz)); } static int bus0_sock_getopt_raw(void *arg, void *buf, size_t *szp) { bus0_sock *s = arg; - return (nni_getopt_int(s->raw, buf, szp)); + return (nni_getopt_bool(s->raw, buf, szp)); } static void diff --git a/src/protocol/pair0/pair.c b/src/protocol/pair0/pair.c index d3591df9..9e9dfe10 100644 --- a/src/protocol/pair0/pair.c +++ b/src/protocol/pair0/pair.c @@ -36,7 +36,7 @@ struct pair0_sock { pair0_pipe *ppipe; nni_msgq * uwq; nni_msgq * urq; - int raw; + bool raw; nni_mtx mtx; }; @@ -63,7 +63,7 @@ pair0_sock_init(void **sp, nni_sock *nsock) } nni_mtx_init(&s->mtx); s->ppipe = NULL; - s->raw = 0; + s->raw = false; s->uwq = nni_sock_sendq(nsock); s->urq = nni_sock_recvq(nsock); *sp = s; @@ -235,14 +235,14 @@ static int pair0_sock_setopt_raw(void *arg, const void *buf, size_t sz) { pair0_sock *s = arg; - return (nni_setopt_int(&s->raw, buf, sz, 0, 1)); + return (nni_setopt_bool(&s->raw, buf, sz)); } static int pair0_sock_getopt_raw(void *arg, void *buf, size_t *szp) { pair0_sock *s = arg; - return (nni_getopt_int(s->raw, buf, szp)); + return (nni_getopt_bool(s->raw, buf, szp)); } static void diff --git a/src/protocol/pair1/pair.c b/src/protocol/pair1/pair.c index 3f6f63fc..b4519221 100644 --- a/src/protocol/pair1/pair.c +++ b/src/protocol/pair1/pair.c @@ -1,6 +1,6 @@ // -// Copyright 2017 Garrett D'Amore <garrett@damore.org> -// Copyright 2017 Capitar IT Group BV <info@capitar.com> +// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2018 Capitar IT Group BV <info@capitar.com> // // This software is supplied under the terms of the MIT License, a // copy of which should be located in the distribution where this @@ -37,13 +37,13 @@ static void pair1_pipe_fini(void *); struct pair1_sock { nni_msgq * uwq; nni_msgq * urq; - int raw; + bool raw; int ttl; nni_mtx mtx; nni_idhash *pipes; nni_list plist; - int started; - int poly; + bool started; + bool poly; nni_aio * aio_getq; }; @@ -94,8 +94,8 @@ pair1_sock_init(void **sp, nni_sock *nsock) return (rv); } - s->raw = 0; - s->poly = 0; + s->raw = false; + s->poly = false; s->uwq = nni_sock_sendq(nsock); s->urq = nni_sock_recvq(nsock); s->ttl = 8; @@ -167,7 +167,7 @@ pair1_pipe_start(void *arg) } } nni_list_append(&s->plist, p); - s->started = 1; + s->started = true; nni_mtx_unlock(&s->mtx); // Schedule a getq. In polyamorous mode we get on the per pipe @@ -402,7 +402,7 @@ pair1_sock_setopt_raw(void *arg, const void *buf, size_t sz) pair1_sock *s = arg; int rv; nni_mtx_lock(&s->mtx); - rv = s->started ? NNG_ESTATE : nni_setopt_int(&s->raw, buf, sz, 0, 1); + rv = s->started ? NNG_ESTATE : nni_setopt_bool(&s->raw, buf, sz); nni_mtx_unlock(&s->mtx); return (rv); } @@ -411,7 +411,7 @@ static int pair1_sock_getopt_raw(void *arg, void *buf, size_t *szp) { pair1_sock *s = arg; - return (nni_getopt_int(s->raw, buf, szp)); + return (nni_getopt_bool(s->raw, buf, szp)); } static int @@ -438,7 +438,7 @@ pair1_sock_setopt_poly(void *arg, const void *buf, size_t sz) pair1_sock *s = arg; int rv; nni_mtx_lock(&s->mtx); - rv = s->started ? NNG_ESTATE : nni_setopt_int(&s->poly, buf, sz, 0, 1); + rv = s->started ? NNG_ESTATE : nni_setopt_bool(&s->poly, buf, sz); nni_mtx_unlock(&s->mtx); return (rv); } @@ -447,7 +447,7 @@ static int pair1_sock_getopt_poly(void *arg, void *buf, size_t *szp) { pair1_sock *s = arg; - return (nni_getopt_int(s->poly, buf, szp)); + return (nni_getopt_bool(s->poly, buf, szp)); } static void diff --git a/src/protocol/pipeline0/pull.c b/src/protocol/pipeline0/pull.c index ccc1ef40..5e0a9d00 100644 --- a/src/protocol/pipeline0/pull.c +++ b/src/protocol/pipeline0/pull.c @@ -34,7 +34,7 @@ static void pull0_putq(pull0_pipe *, nni_msg *); // pull0_sock is our per-socket protocol private structure. struct pull0_sock { nni_msgq *urq; - int raw; + bool raw; }; // pull0_pipe is our per-pipe protocol private structure. @@ -53,7 +53,7 @@ pull0_sock_init(void **sp, nni_sock *sock) if ((s = NNI_ALLOC_STRUCT(s)) == NULL) { return (NNG_ENOMEM); } - s->raw = 0; + s->raw = false; s->urq = nni_sock_recvq(sock); *sp = s; @@ -184,14 +184,14 @@ static int pull0_sock_setopt_raw(void *arg, const void *buf, size_t sz) { pull0_sock *s = arg; - return (nni_setopt_int(&s->raw, buf, sz, 0, 1)); + return (nni_setopt_bool(&s->raw, buf, sz)); } static int pull0_sock_getopt_raw(void *arg, void *buf, size_t *szp) { pull0_sock *s = arg; - return (nni_getopt_int(s->raw, buf, szp)); + return (nni_getopt_bool(s->raw, buf, szp)); } static void diff --git a/src/protocol/pipeline0/push.c b/src/protocol/pipeline0/push.c index e77bfe99..a0dfa397 100644 --- a/src/protocol/pipeline0/push.c +++ b/src/protocol/pipeline0/push.c @@ -36,7 +36,7 @@ static void push0_getq_cb(void *); // push0_sock is our per-socket protocol private structure. struct push0_sock { nni_msgq *uwq; - int raw; + bool raw; }; // push0_pipe is our per-pipe protocol private structure. @@ -58,7 +58,7 @@ push0_sock_init(void **sp, nni_sock *sock) if ((s = NNI_ALLOC_STRUCT(s)) == NULL) { return (NNG_ENOMEM); } - s->raw = 0; + s->raw = false; s->uwq = nni_sock_sendq(sock); *sp = s; return (0); @@ -201,14 +201,14 @@ static int push0_sock_setopt_raw(void *arg, const void *buf, size_t sz) { push0_sock *s = arg; - return (nni_setopt_int(&s->raw, buf, sz, 0, 1)); + return (nni_setopt_bool(&s->raw, buf, sz)); } static int push0_sock_getopt_raw(void *arg, void *buf, size_t *szp) { push0_sock *s = arg; - return (nni_getopt_int(s->raw, buf, szp)); + return (nni_getopt_bool(s->raw, buf, szp)); } static void diff --git a/src/protocol/pubsub0/pub.c b/src/protocol/pubsub0/pub.c index 33ecb5ba..ff110d56 100644 --- a/src/protocol/pubsub0/pub.c +++ b/src/protocol/pubsub0/pub.c @@ -40,7 +40,7 @@ static void pub0_pipe_fini(void *); // pub0_sock is our per-socket protocol private structure. struct pub0_sock { nni_msgq *uwq; - int raw; + bool raw; nni_aio * aio_getq; nni_list pipes; nni_mtx mtx; @@ -83,7 +83,7 @@ pub0_sock_init(void **sp, nni_sock *sock) return (rv); } - s->raw = 0; + s->raw = false; NNI_LIST_INIT(&s->pipes, pub0_pipe, node); s->uwq = nni_sock_sendq(sock); @@ -277,14 +277,14 @@ static int pub0_sock_setopt_raw(void *arg, const void *buf, size_t sz) { pub0_sock *s = arg; - return (nni_setopt_int(&s->raw, buf, sz, 0, 1)); + return (nni_setopt_bool(&s->raw, buf, sz)); } static int pub0_sock_getopt_raw(void *arg, void *buf, size_t *szp) { pub0_sock *s = arg; - return (nni_getopt_int(s->raw, buf, szp)); + return (nni_getopt_bool(s->raw, buf, szp)); } static void diff --git a/src/protocol/pubsub0/sub.c b/src/protocol/pubsub0/sub.c index 8803ab19..d9d0d5f3 100644 --- a/src/protocol/pubsub0/sub.c +++ b/src/protocol/pubsub0/sub.c @@ -44,7 +44,7 @@ struct sub0_topic { struct sub0_sock { nni_list topics; nni_msgq *urq; - int raw; + bool raw; nni_mtx lk; }; @@ -66,7 +66,7 @@ sub0_sock_init(void **sp, nni_sock *sock) } nni_mtx_init(&s->lk); NNI_LIST_INIT(&s->topics, sub0_topic, node); - s->raw = 0; + s->raw = false; s->urq = nni_sock_recvq(sock); *sp = s; @@ -279,14 +279,14 @@ static int sub0_sock_setopt_raw(void *arg, const void *buf, size_t sz) { sub0_sock *s = arg; - return (nni_setopt_int(&s->raw, buf, sz, 0, 1)); + return (nni_setopt_bool(&s->raw, buf, sz)); } static int sub0_sock_getopt_raw(void *arg, void *buf, size_t *szp) { sub0_sock *s = arg; - return (nni_getopt_int(s->raw, buf, szp)); + return (nni_getopt_bool(s->raw, buf, szp)); } static void 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); 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 |
