aboutsummaryrefslogtreecommitdiff
path: root/src/protocol/reqrep/req.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-08-08 00:33:19 -0700
committerGarrett D'Amore <garrett@damore.org>2017-08-08 00:33:19 -0700
commit50532054c0bee3a1ff3324db10f3cdf7b44041e4 (patch)
tree6e924d21e7eb188865d98e9daa203a045cc928c5 /src/protocol/reqrep/req.c
parent702fe1d0af4b08a8b53172aaca57394b181d58b2 (diff)
downloadnng-50532054c0bee3a1ff3324db10f3cdf7b44041e4.tar.gz
nng-50532054c0bee3a1ff3324db10f3cdf7b44041e4.tar.bz2
nng-50532054c0bee3a1ff3324db10f3cdf7b44041e4.zip
Added nn_compat code for option handling, fixed other bugs.
Hop counts for REQ were busted (bad TTL), and imported the compat_reqtll test. At the same time, added code to nn_term to shut down completely, discarding sockets. (Note that some things, such as globals, may still be left around; that's ok.)
Diffstat (limited to 'src/protocol/reqrep/req.c')
-rw-r--r--src/protocol/reqrep/req.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/protocol/reqrep/req.c b/src/protocol/reqrep/req.c
index 8e7056f5..7ec53c90 100644
--- a/src/protocol/reqrep/req.c
+++ b/src/protocol/reqrep/req.c
@@ -35,6 +35,7 @@ struct nni_req_sock {
int raw;
int wantw;
int closed;
+ int ttl;
nni_msg * reqmsg;
nni_req_pipe *pendpipe;
@@ -101,6 +102,7 @@ nni_req_sock_init(void **reqp, nni_sock *sock)
req->raw = 0;
req->wantw = 0;
req->resend = NNI_TIME_ZERO;
+ req->ttl = 8;
req->uwq = nni_sock_sendq(sock);
req->urq = nni_sock_recvq(sock);
@@ -269,6 +271,12 @@ nni_req_sock_setopt(void *arg, int opt, const void *buf, size_t sz)
break;
case NNG_OPT_RAW:
rv = nni_setopt_int(&req->raw, buf, sz, 0, 1);
+ if (rv == 0) {
+ nni_sock_recverr(req->sock, req->raw ? 0 : NNG_ESTATE);
+ }
+ break;
+ case NNG_OPT_MAXTTL:
+ rv = nni_setopt_int(&req->ttl, buf, sz, 1, 255);
break;
default:
rv = NNG_ENOTSUP;
@@ -289,6 +297,9 @@ nni_req_sock_getopt(void *arg, int opt, void *buf, size_t *szp)
case NNG_OPT_RAW:
rv = nni_getopt_int(&req->raw, buf, szp);
break;
+ case NNG_OPT_MAXTTL:
+ rv = nni_getopt_int(&req->ttl, buf, szp);
+ break;
default:
rv = NNG_ENOTSUP;
}