diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-10-19 15:16:25 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-10-19 17:56:49 -0700 |
| commit | 4e668fdd5b5da0d46f97d835249dbe5f0ea319a7 (patch) | |
| tree | 0aaad8a672024b3a510763150b167320be6f1f5b /tests/pipeline.c | |
| parent | d7e39a2423212a31c5ef62dcb0b7a5b4bf9f34df (diff) | |
| download | nng-4e668fdd5b5da0d46f97d835249dbe5f0ea319a7.tar.gz nng-4e668fdd5b5da0d46f97d835249dbe5f0ea319a7.tar.bz2 nng-4e668fdd5b5da0d46f97d835249dbe5f0ea319a7.zip | |
fixes #84 Consider using msec for durations
There is now a public nng_duration type. We have also updated the
zerotier work to work with the signed int64_t's that the latst ZeroTier
dev branch is using.
Diffstat (limited to 'tests/pipeline.c')
| -rw-r--r-- | tests/pipeline.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/tests/pipeline.c b/tests/pipeline.c index c7ac2dd0..a7718dd6 100644 --- a/tests/pipeline.c +++ b/tests/pipeline.c @@ -16,6 +16,7 @@ #define CHECKSTR(m, s) \ So(nng_msg_len(m) == strlen(s)); \ So(memcmp(nng_msg_body(m), s, strlen(s)) == 0) +#define MILLISECOND(x) (x) TestMain("PIPELINE (PUSH/PULL) pattern", { atexit(nng_fini); @@ -80,7 +81,7 @@ TestMain("PIPELINE (PUSH/PULL) pattern", { So(nng_dial(what, addr, NULL, 0) == 0); So(nng_shutdown(what) == 0); - nng_usleep(20000); + nng_msleep(20); Convey("Push can send messages, and pull can recv", { nng_msg *msg; @@ -97,13 +98,13 @@ TestMain("PIPELINE (PUSH/PULL) pattern", { }); Convey("Load balancing", { - nng_msg * abc; - nng_msg * def; - uint64_t usecs; - nng_socket push; - nng_socket pull1; - nng_socket pull2; - nng_socket pull3; + nng_msg * abc; + nng_msg * def; + nng_duration msecs; + nng_socket push; + nng_socket pull1; + nng_socket pull2; + nng_socket pull3; So(nng_push_open(&push) == 0); So(nng_pull_open(&pull1) == 0); @@ -137,10 +138,10 @@ TestMain("PIPELINE (PUSH/PULL) pattern", { So(nng_msg_alloc(&def, 0) == 0); APPENDSTR(def, "def"); - usecs = 100000; - So(nng_setopt_usec(pull1, NNG_OPT_RECVTIMEO, usecs) == 0); - So(nng_setopt_usec(pull2, NNG_OPT_RECVTIMEO, usecs) == 0); - So(nng_setopt_usec(pull3, NNG_OPT_RECVTIMEO, usecs) == 0); + msecs = MILLISECOND(100); + So(nng_setopt_ms(pull1, NNG_OPT_RECVTIMEO, msecs) == 0); + So(nng_setopt_ms(pull2, NNG_OPT_RECVTIMEO, msecs) == 0); + So(nng_setopt_ms(pull3, NNG_OPT_RECVTIMEO, msecs) == 0); So(nng_listen(push, addr, NULL, 0) == 0); So(nng_dial(pull1, addr, NULL, 0) == 0); So(nng_dial(pull2, addr, NULL, 0) == 0); @@ -152,7 +153,7 @@ TestMain("PIPELINE (PUSH/PULL) pattern", { // server couldn't have gotten to the accept. (The // accept logic is single threaded.) Let's wait a bit // though, to ensure that stuff has settled. - nng_usleep(100000); + nng_msleep(100); So(nng_sendmsg(push, abc, 0) == 0); So(nng_sendmsg(push, def, 0) == 0); |
