aboutsummaryrefslogtreecommitdiff
path: root/src/protocol/survey0/xsurvey.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2020-01-20 23:31:55 -0800
committerGarrett D'Amore <garrett@damore.org>2020-01-20 23:35:08 -0800
commit38c005e7c07b5ccaab3345dc8c66cbc27b95692a (patch)
tree7d35c74df9f0f320942e6c8c601e963a4cc11741 /src/protocol/survey0/xsurvey.c
parent058ad941dc55ad6288f6b07f4cdf237fd13f1a93 (diff)
downloadnng-38c005e7c07b5ccaab3345dc8c66cbc27b95692a.tar.gz
nng-38c005e7c07b5ccaab3345dc8c66cbc27b95692a.tar.bz2
nng-38c005e7c07b5ccaab3345dc8c66cbc27b95692a.zip
fixes #1169 survey and xsurvey could use message cloning
fixes #1160 Consider limiting maximum hop count to 15 fixes #1098 Maximum maxTTL should be compile time defined This doesn't expose the max-MaxTTL in the CMakeList.txt -- there is really no reason anyone should be changing it. This does not yet inline the message header into the nni_msg_t, but it is my intention to do so soon, and eliminate most of the conditional cases for failure on inserting into the header.
Diffstat (limited to 'src/protocol/survey0/xsurvey.c')
-rw-r--r--src/protocol/survey0/xsurvey.c24
1 files changed, 7 insertions, 17 deletions
diff --git a/src/protocol/survey0/xsurvey.c b/src/protocol/survey0/xsurvey.c
index 7a5a5c1b..2a198662 100644
--- a/src/protocol/survey0/xsurvey.c
+++ b/src/protocol/survey0/xsurvey.c
@@ -273,7 +273,7 @@ xsurv0_sock_set_max_ttl(void *arg, const void *buf, size_t sz, nni_opt_type t)
xsurv0_sock *s = arg;
int ttl;
int rv;
- if ((rv = nni_copyin_int(&ttl, buf, sz, 1, 255, t)) == 0) {
+ if ((rv = nni_copyin_int(&ttl, buf, sz, 1, NNI_MAX_MAX_TTL, t)) == 0) {
nni_atomic_set(&s->ttl, ttl);
}
return (rv);
@@ -291,8 +291,7 @@ xsurv0_sock_getq_cb(void *arg)
{
xsurv0_sock *s = arg;
xsurv0_pipe *p;
- xsurv0_pipe *last;
- nni_msg * msg, *dup;
+ nni_msg * msg;
if (nni_aio_result(&s->aio_getq) != 0) {
// Should be NNG_ECLOSED.
@@ -302,27 +301,18 @@ xsurv0_sock_getq_cb(void *arg)
nni_aio_set_msg(&s->aio_getq, NULL);
nni_mtx_lock(&s->mtx);
- last = nni_list_last(&s->pipes);
NNI_LIST_FOREACH (&s->pipes, p) {
- if (p != last) {
- if (nni_msg_dup(&dup, msg) != 0) {
- continue;
- }
- } else {
- dup = msg;
- }
- if (nni_msgq_tryput(p->sendq, dup) != 0) {
- nni_msg_free(dup);
+ nni_msg_clone(msg);
+ if (nni_msgq_tryput(p->sendq, msg) != 0) {
+ nni_msg_free(msg);
}
}
nni_msgq_aio_get(s->uwq, &s->aio_getq);
nni_mtx_unlock(&s->mtx);
- if (last == NULL) {
- // If there were no pipes to send on, just toss the message.
- nni_msg_free(msg);
- }
+ // If there were no pipes to send on, just toss the message.
+ nni_msg_free(msg);
}
static void