From 64db0f085be0c9efc6dca8d9e72d3e5a47cb792e Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Mon, 25 Sep 2017 12:49:10 -0700 Subject: Refactor option handling APIs. This makes the APIs use string keys, and largely eliminates the use of integer option IDs altogether. The underlying registration for options is also now a bit richer, letting protcols and transports declare the actual options they use, rather than calling down into each entry point carte blanche and relying on ENOTSUP. This code may not be as fast as the integers was, but it is more intuitive, easier to extend, and is not on any hot code paths. (If you're diddling options on a hot code path you're doing something wrong.) --- tests/reqrep.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) (limited to 'tests/reqrep.c') diff --git a/tests/reqrep.c b/tests/reqrep.c index 537d45c8..c31f0212 100644 --- a/tests/reqrep.c +++ b/tests/reqrep.c @@ -13,9 +13,6 @@ #include -extern const char *nng_opt_req_resendtime; -extern int nng_optid_req_resendtime; - TestMain("REQ/REP pattern", { int rv; const char *addr = "inproc://test"; @@ -32,19 +29,13 @@ TestMain("REQ/REP pattern", { }); Convey("Resend time option id works", { - int opt; - const char *name; - opt = nng_option_lookup(nng_opt_req_resendtime); - So(opt >= 0); - So(opt == nng_optid_req_resendtime); - name = nng_option_name(opt); - So(name != NULL); - So(strcmp(name, nng_opt_req_resendtime) == 0); // Set timeout. - So(nng_setopt_usec(req, opt, 10000) == 0); + So(nng_setopt_usec( + req, NNG_OPT_REQ_RESENDTIME, 10000) == 0); // Check invalid size - So(nng_setopt(req, opt, name, 1) == NNG_EINVAL); + So(nng_setopt(req, NNG_OPT_REQ_RESENDTIME, "", 1) == + NNG_EINVAL); }); Convey("Recv with no send fails", { @@ -75,8 +66,8 @@ TestMain("REQ/REP pattern", { }); Convey("Cannot set resend time", { - So(nng_setopt_usec(rep, nng_optid_req_resendtime, - 100) == NNG_ENOTSUP); + So(nng_setopt_usec(rep, NNG_OPT_REQ_RESENDTIME, 100) == + NNG_ENOTSUP); }); }); @@ -140,8 +131,8 @@ TestMain("REQ/REP pattern", { nng_close(req); }); - So(nng_setopt_usec(req, nng_optid_req_resendtime, retry) == 0); - So(nng_setopt_int(req, nng_optid_sendbuf, 16) == 0); + So(nng_setopt_usec(req, NNG_OPT_REQ_RESENDTIME, retry) == 0); + So(nng_setopt_int(req, NNG_OPT_SENDBUF, 16) == 0); So(nng_msg_alloc(&abc, 0) == 0); So(nng_msg_append(abc, "abc", 4) == 0); -- cgit v1.2.3-70-g09d2