diff options
Diffstat (limited to 'src/protocol/reqrep0')
| -rw-r--r-- | src/protocol/reqrep0/rep.c | 4 | ||||
| -rw-r--r-- | src/protocol/reqrep0/req.c | 11 | ||||
| -rw-r--r-- | src/protocol/reqrep0/req_test.c | 3 | ||||
| -rw-r--r-- | src/protocol/reqrep0/xrep.c | 2 | ||||
| -rw-r--r-- | src/protocol/reqrep0/xrep_test.c | 1 | ||||
| -rw-r--r-- | src/protocol/reqrep0/xreq.c | 2 | ||||
| -rw-r--r-- | src/protocol/reqrep0/xreq_test.c | 1 |
7 files changed, 13 insertions, 11 deletions
diff --git a/src/protocol/reqrep0/rep.c b/src/protocol/reqrep0/rep.c index ef3f548a..d0cc0d55 100644 --- a/src/protocol/reqrep0/rep.c +++ b/src/protocol/reqrep0/rep.c @@ -34,7 +34,7 @@ struct rep0_ctx { nni_list_node sqnode; nni_list_node rqnode; size_t btrace_len; - uint32_t btrace[256]; // backtrace buffer + uint32_t btrace[NNI_MAX_MAX_TTL + 1]; }; // rep0_sock is our per-socket protocol private structure. @@ -573,7 +573,7 @@ rep0_sock_set_max_ttl(void *arg, const void *buf, size_t sz, nni_opt_type t) 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); diff --git a/src/protocol/reqrep0/req.c b/src/protocol/reqrep0/req.c index b8ca498d..fea95725 100644 --- a/src/protocol/reqrep0/req.c +++ b/src/protocol/reqrep0/req.c @@ -666,12 +666,9 @@ req0_ctx_send(void *arg, nni_aio *aio) return; } ctx->request_id = (uint32_t) id; - if ((rv = nni_msg_header_append_u32(msg, ctx->request_id)) != 0) { - nni_idhash_remove(s->requests, id); - nni_mtx_unlock(&s->mtx); - nni_aio_finish_error(aio, rv); - return; - } + nni_msg_header_clear(msg); + nni_msg_header_must_append_u32(msg, ctx->request_id); + // If no pipes are ready, and the request was a poll (no background // schedule), then fail it. Should be NNG_ETIMEDOUT. rv = nni_aio_schedule(aio, req0_ctx_cancel_send, ctx); @@ -713,7 +710,7 @@ req0_sock_set_max_ttl(void *arg, const void *buf, size_t sz, nni_opt_type t) req0_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); diff --git a/src/protocol/reqrep0/req_test.c b/src/protocol/reqrep0/req_test.c index 2524dfd2..6cb06f62 100644 --- a/src/protocol/reqrep0/req_test.c +++ b/src/protocol/reqrep0/req_test.c @@ -52,6 +52,9 @@ test_req_ttl_option(void) TEST_NNG_PASS(nng_setopt_int(req, opt, 1)); TEST_NNG_FAIL(nng_setopt_int(req, opt, 0), NNG_EINVAL); TEST_NNG_FAIL(nng_setopt_int(req, opt, -1), NNG_EINVAL); + // This test will fail if the NNI_MAX_MAX_TTL is changed from the + // builtin default of 15. + TEST_NNG_FAIL(nng_setopt_int(req, opt, 16), NNG_EINVAL); TEST_NNG_FAIL(nng_setopt_int(req, opt, 256), NNG_EINVAL); TEST_NNG_PASS(nng_setopt_int(req, opt, 3)); TEST_NNG_PASS(nng_getopt_int(req, opt, &v)); diff --git a/src/protocol/reqrep0/xrep.c b/src/protocol/reqrep0/xrep.c index e63cfe83..901cecc4 100644 --- a/src/protocol/reqrep0/xrep.c +++ b/src/protocol/reqrep0/xrep.c @@ -355,7 +355,7 @@ xrep0_sock_set_maxttl(void *arg, const void *buf, size_t sz, nni_opt_type t) xrep0_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); diff --git a/src/protocol/reqrep0/xrep_test.c b/src/protocol/reqrep0/xrep_test.c index 33d834df..8fc36964 100644 --- a/src/protocol/reqrep0/xrep_test.c +++ b/src/protocol/reqrep0/xrep_test.c @@ -337,6 +337,7 @@ test_xrep_ttl_option(void) TEST_NNG_PASS(nng_setopt_int(rep, opt, 1)); TEST_NNG_FAIL(nng_setopt_int(rep, opt, 0), NNG_EINVAL); TEST_NNG_FAIL(nng_setopt_int(rep, opt, -1), NNG_EINVAL); + TEST_NNG_FAIL(nng_setopt_int(rep, opt, 16), NNG_EINVAL); TEST_NNG_FAIL(nng_setopt_int(rep, opt, 256), NNG_EINVAL); TEST_NNG_PASS(nng_setopt_int(rep, opt, 3)); TEST_NNG_PASS(nng_getopt_int(rep, opt, &v)); diff --git a/src/protocol/reqrep0/xreq.c b/src/protocol/reqrep0/xreq.c index 4900fb06..bcb218bf 100644 --- a/src/protocol/reqrep0/xreq.c +++ b/src/protocol/reqrep0/xreq.c @@ -257,7 +257,7 @@ xreq0_sock_set_max_ttl(void *arg, const void *buf, size_t sz, nni_opt_type t) xreq0_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); diff --git a/src/protocol/reqrep0/xreq_test.c b/src/protocol/reqrep0/xreq_test.c index 57ad7f0a..68a7c7f5 100644 --- a/src/protocol/reqrep0/xreq_test.c +++ b/src/protocol/reqrep0/xreq_test.c @@ -337,6 +337,7 @@ test_xreq_ttl_option(void) TEST_NNG_PASS(nng_setopt_int(rep, opt, 1)); TEST_NNG_FAIL(nng_setopt_int(rep, opt, 0), NNG_EINVAL); TEST_NNG_FAIL(nng_setopt_int(rep, opt, -1), NNG_EINVAL); + TEST_NNG_FAIL(nng_setopt_int(rep, opt, 16), NNG_EINVAL); TEST_NNG_FAIL(nng_setopt_int(rep, opt, 256), NNG_EINVAL); TEST_NNG_PASS(nng_setopt_int(rep, opt, 3)); TEST_NNG_PASS(nng_getopt_int(rep, opt, &v)); |
