diff options
| -rw-r--r-- | src/core/options.c | 4 | ||||
| -rw-r--r-- | src/core/options.h | 4 | ||||
| -rw-r--r-- | src/core/socket.c | 26 | ||||
| -rw-r--r-- | src/core/socket.h | 5 | ||||
| -rw-r--r-- | src/nng.c | 4 | ||||
| -rw-r--r-- | src/nng.h | 4 | ||||
| -rw-r--r-- | src/protocol/reqrep/req.c | 4 | ||||
| -rw-r--r-- | src/protocol/survey/survey.c | 4 | ||||
| -rw-r--r-- | tests/pair1.c | 14 | ||||
| -rw-r--r-- | tests/reqrep.c | 2 | ||||
| -rw-r--r-- | tests/sock.c | 18 |
11 files changed, 40 insertions, 49 deletions
diff --git a/src/core/options.c b/src/core/options.c index 170e7407..403630a3 100644 --- a/src/core/options.c +++ b/src/core/options.c @@ -13,7 +13,7 @@ #include <string.h> int -nni_setopt_duration(nni_duration *ptr, const void *val, size_t size) +nni_setopt_usec(nni_duration *ptr, const void *val, size_t size) { nni_duration dur; @@ -68,7 +68,7 @@ nni_setopt_size( } int -nni_getopt_duration(nni_duration *ptr, void *val, size_t *sizep) +nni_getopt_usec(nni_duration *ptr, void *val, size_t *sizep) { size_t sz = sizeof(*ptr); diff --git a/src/core/options.h b/src/core/options.h index 4f958e55..8e6e1edf 100644 --- a/src/core/options.h +++ b/src/core/options.h @@ -22,10 +22,10 @@ extern int nni_getopt_buf(nni_msgq *, void *, size_t *); // nni_setopt_duration sets the duration. Durations must be legal, // either a positive value, 0, or -1 to indicate forever. -extern int nni_setopt_duration(nni_duration *, const void *, size_t); +extern int nni_setopt_usec(nni_duration *, const void *, size_t); // nni_getopt_duration gets the duration. -extern int nni_getopt_duration(nni_duration *, void *, size_t *); +extern int nni_getopt_usec(nni_duration *, void *, size_t *); // nni_setopt_int sets an integer, which must be between the minimum and // maximum values (inclusive). diff --git a/src/core/socket.c b/src/core/socket.c index 51ea9b55..541c2383 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -632,12 +632,6 @@ nni_sock_peer(nni_sock *sock) return (sock->s_peer_id.p_id); } -nni_duration -nni_sock_linger(nni_sock *sock) -{ - return (sock->s_linger); -} - size_t nni_sock_rcvmaxsz(nni_sock *sock) { @@ -712,19 +706,19 @@ nni_sock_setopt(nni_sock *sock, int opt, const void *val, size_t size) } switch (opt) { case NNG_OPT_LINGER: - rv = nni_setopt_duration(&sock->s_linger, val, size); + rv = nni_setopt_usec(&sock->s_linger, val, size); break; case NNG_OPT_SNDTIMEO: - rv = nni_setopt_duration(&sock->s_sndtimeo, val, size); + rv = nni_setopt_usec(&sock->s_sndtimeo, val, size); break; case NNG_OPT_RCVTIMEO: - rv = nni_setopt_duration(&sock->s_rcvtimeo, val, size); + rv = nni_setopt_usec(&sock->s_rcvtimeo, val, size); break; case NNG_OPT_RECONN_TIME: - rv = nni_setopt_duration(&sock->s_reconn, val, size); + rv = nni_setopt_usec(&sock->s_reconn, val, size); break; case NNG_OPT_RECONN_MAXTIME: - rv = nni_setopt_duration(&sock->s_reconnmax, val, size); + rv = nni_setopt_usec(&sock->s_reconnmax, val, size); break; case NNG_OPT_SNDBUF: rv = nni_setopt_buf(sock->s_uwq, val, size); @@ -762,19 +756,19 @@ nni_sock_getopt(nni_sock *sock, int opt, void *val, size_t *sizep) switch (opt) { case NNG_OPT_LINGER: - rv = nni_getopt_duration(&sock->s_linger, val, sizep); + rv = nni_getopt_usec(&sock->s_linger, val, sizep); break; case NNG_OPT_SNDTIMEO: - rv = nni_getopt_duration(&sock->s_sndtimeo, val, sizep); + rv = nni_getopt_usec(&sock->s_sndtimeo, val, sizep); break; case NNG_OPT_RCVTIMEO: - rv = nni_getopt_duration(&sock->s_rcvtimeo, val, sizep); + rv = nni_getopt_usec(&sock->s_rcvtimeo, val, sizep); break; case NNG_OPT_RECONN_TIME: - rv = nni_getopt_duration(&sock->s_reconn, val, sizep); + rv = nni_getopt_usec(&sock->s_reconn, val, sizep); break; case NNG_OPT_RECONN_MAXTIME: - rv = nni_getopt_duration(&sock->s_reconnmax, val, sizep); + rv = nni_getopt_usec(&sock->s_reconnmax, val, sizep); break; case NNG_OPT_SNDBUF: rv = nni_getopt_buf(sock->s_uwq, val, sizep); diff --git a/src/core/socket.h b/src/core/socket.h index 94dd816d..9b7ac1f9 100644 --- a/src/core/socket.h +++ b/src/core/socket.h @@ -112,8 +112,7 @@ extern nni_msgq *nni_sock_sendq(nni_sock *); // inject incoming messages from pipes to it. extern nni_msgq *nni_sock_recvq(nni_sock *); -extern nni_duration nni_sock_linger(nni_sock *); -extern size_t nni_sock_rcvmaxsz(nni_sock *); -extern void nni_sock_reconntimes(nni_sock *, nni_duration *, nni_duration *); +extern size_t nni_sock_rcvmaxsz(nni_sock *); +extern void nni_sock_reconntimes(nni_sock *, nni_duration *, nni_duration *); #endif // CORE_SOCKET_H @@ -384,7 +384,7 @@ nng_setopt_size(nng_socket sid, int opt, size_t val) } int -nng_setopt_duration(nng_socket sid, int opt, uint64_t val) +nng_setopt_usec(nng_socket sid, int opt, uint64_t val) { return (nng_setopt(sid, opt, &val, sizeof(val))); } @@ -404,7 +404,7 @@ nng_getopt_size(nng_socket sid, int opt, size_t *valp) } int -nng_getopt_duration(nng_socket sid, int opt, uint64_t *valp) +nng_getopt_usec(nng_socket sid, int opt, uint64_t *valp) { size_t sz = sizeof(*valp); return (nng_getopt(sid, opt, valp, &sz)); @@ -88,13 +88,13 @@ NNG_DECL uint16_t nng_peer(nng_socket); // nng_setopt sets an option for a specific socket. NNG_DECL int nng_setopt(nng_socket, int, const void *, size_t); NNG_DECL int nng_setopt_int(nng_socket, int, int); -NNG_DECL int nng_setopt_duration(nng_socket, int, uint64_t); +NNG_DECL int nng_setopt_usec(nng_socket, int, uint64_t); NNG_DECL int nng_setopt_size(nng_socket, int, size_t); // nng_socket_getopt obtains the option for a socket. NNG_DECL int nng_getopt(nng_socket, int, void *, size_t *); NNG_DECL int nng_getopt_int(nng_socket, int, int *); -NNG_DECL int nng_getopt_duration(nng_socket, int, uint64_t *); +NNG_DECL int nng_getopt_usec(nng_socket, int, uint64_t *); NNG_DECL int nng_getopt_size(nng_socket, int, size_t *); // nng_notify_func is a user function that is executed upon certain diff --git a/src/protocol/reqrep/req.c b/src/protocol/reqrep/req.c index 20fb07f8..fdf29fd9 100644 --- a/src/protocol/reqrep/req.c +++ b/src/protocol/reqrep/req.c @@ -273,7 +273,7 @@ nni_req_sock_setopt(void *arg, int opt, const void *buf, size_t sz) switch (opt) { case NNG_OPT_RESENDTIME: - rv = nni_setopt_duration(&req->retry, buf, sz); + rv = nni_setopt_usec(&req->retry, buf, sz); break; case NNG_OPT_RAW: rv = nni_setopt_int(&req->raw, buf, sz, 0, 1); @@ -298,7 +298,7 @@ nni_req_sock_getopt(void *arg, int opt, void *buf, size_t *szp) switch (opt) { case NNG_OPT_RESENDTIME: - rv = nni_getopt_duration(&req->retry, buf, szp); + rv = nni_getopt_usec(&req->retry, buf, szp); break; case NNG_OPT_RAW: rv = nni_getopt_int(&req->raw, buf, szp); diff --git a/src/protocol/survey/survey.c b/src/protocol/survey/survey.c index 45b06d67..cb90c13f 100644 --- a/src/protocol/survey/survey.c +++ b/src/protocol/survey/survey.c @@ -295,7 +295,7 @@ nni_surv_sock_setopt(void *arg, int opt, const void *buf, size_t sz) switch (opt) { case NNG_OPT_SURVEYTIME: - rv = nni_setopt_duration(&psock->survtime, buf, sz); + rv = nni_setopt_usec(&psock->survtime, buf, sz); break; case NNG_OPT_RAW: oldraw = psock->raw; @@ -324,7 +324,7 @@ nni_surv_sock_getopt(void *arg, int opt, void *buf, size_t *szp) switch (opt) { case NNG_OPT_SURVEYTIME: - rv = nni_getopt_duration(&psock->survtime, buf, szp); + rv = nni_getopt_usec(&psock->survtime, buf, szp); break; case NNG_OPT_RAW: rv = nni_getopt_int(&psock->raw, buf, szp); diff --git a/tests/pair1.c b/tests/pair1.c index aa86883b..08691fd4 100644 --- a/tests/pair1.c +++ b/tests/pair1.c @@ -44,11 +44,11 @@ TestMain("PAIRv1 protocol", { So(nng_pair1_open(&c2) == 0); tmo = 300000; - So(nng_setopt_duration(s1, NNG_OPT_RCVTIMEO, tmo) == 0); - So(nng_setopt_duration(c1, NNG_OPT_RCVTIMEO, tmo) == 0); - So(nng_setopt_duration(c2, NNG_OPT_RCVTIMEO, tmo) == 0); + So(nng_setopt_usec(s1, NNG_OPT_RCVTIMEO, tmo) == 0); + So(nng_setopt_usec(c1, NNG_OPT_RCVTIMEO, tmo) == 0); + So(nng_setopt_usec(c2, NNG_OPT_RCVTIMEO, tmo) == 0); tmo = 0; - So(nng_getopt_duration(s1, NNG_OPT_RCVTIMEO, &tmo) == 0); + So(nng_getopt_usec(s1, NNG_OPT_RCVTIMEO, &tmo) == 0); So(tmo == 300000); Convey("Monogamous cooked mode works", { @@ -113,8 +113,7 @@ TestMain("PAIRv1 protocol", { So(nng_setopt_int(s1, NNG_OPT_RCVBUF, 1) == 0); So(nng_setopt_int(s1, NNG_OPT_SNDBUF, 1) == 0); So(nng_setopt_int(c1, NNG_OPT_RCVBUF, 1) == 0); - So(nng_setopt_duration(s1, NNG_OPT_SNDTIMEO, 100000) == - 0); + So(nng_setopt_usec(s1, NNG_OPT_SNDTIMEO, 100000) == 0); So(nng_listen(s1, addr, NULL, 0) == 0); So(nng_dial(c1, addr, NULL, 0) == 0); @@ -138,8 +137,7 @@ TestMain("PAIRv1 protocol", { So(nng_setopt_int(s1, NNG_OPT_RCVBUF, 1) == 0); So(nng_setopt_int(s1, NNG_OPT_SNDBUF, 1) == 0); So(nng_setopt_int(c1, NNG_OPT_RCVBUF, 1) == 0); - So(nng_setopt_duration(s1, NNG_OPT_SNDTIMEO, 30000) == - 0); + So(nng_setopt_usec(s1, NNG_OPT_SNDTIMEO, 30000) == 0); So(nng_listen(s1, addr, NULL, 0) == 0); So(nng_dial(c1, addr, NULL, 0) == 0); diff --git a/tests/reqrep.c b/tests/reqrep.c index b27af5ac..e36232b6 100644 --- a/tests/reqrep.c +++ b/tests/reqrep.c @@ -115,7 +115,7 @@ TestMain("REQ/REP pattern", { nng_close(req); }); - So(nng_setopt_duration(req, NNG_OPT_RESENDTIME, retry) == 0); + So(nng_setopt_usec(req, NNG_OPT_RESENDTIME, retry) == 0); So(nng_setopt_int(req, NNG_OPT_SNDBUF, 16) == 0); So(nng_msg_alloc(&abc, 0) == 0); diff --git a/tests/sock.c b/tests/sock.c index 31d48333..d33b0c81 100644 --- a/tests/sock.c +++ b/tests/sock.c @@ -60,7 +60,7 @@ TestMain("Socket Operations", { now = nng_clock(); So(now > 0); - So(nng_setopt_duration(s1, NNG_OPT_RCVTIMEO, to) == 0); + So(nng_setopt_usec(s1, NNG_OPT_RCVTIMEO, to) == 0); So(nng_recvmsg(s1, &msg, 0) == NNG_ETIMEDOUT); So(msg == NULL); So(nng_clock() >= (now + to)); @@ -84,7 +84,7 @@ TestMain("Socket Operations", { So(msg != NULL); now = nng_clock(); - So(nng_setopt_duration(s1, NNG_OPT_SNDTIMEO, to) == 0); + So(nng_setopt_usec(s1, NNG_OPT_SNDTIMEO, to) == 0); So(nng_sendmsg(s1, msg, 0) == NNG_ETIMEDOUT); So(nng_clock() >= (now + to)); So(nng_clock() < (now + (to * 2))); @@ -96,7 +96,7 @@ TestMain("Socket Operations", { int64_t v = 0; size_t sz; - So(nng_setopt_duration(s1, NNG_OPT_SNDTIMEO, to) == 0); + So(nng_setopt_usec(s1, NNG_OPT_SNDTIMEO, to) == 0); Convey("Short size is not copied", { sz = 0; @@ -129,8 +129,8 @@ TestMain("Socket Operations", { }); Convey("Negative timeout fails", { - So(nng_setopt_duration(s1, NNG_OPT_RCVTIMEO, - -5) == NNG_EINVAL); + So(nng_setopt_usec(s1, NNG_OPT_RCVTIMEO, -5) == + NNG_EINVAL); }); Convey("Short timeout fails", { @@ -256,10 +256,10 @@ TestMain("Socket Operations", { So(nng_setopt_int(s1, NNG_OPT_SNDBUF, 1) == 0); So(nng_setopt_int(s2, NNG_OPT_SNDBUF, 1) == 0); - So(nng_setopt_duration(s1, NNG_OPT_SNDTIMEO, to) == 0); - So(nng_setopt_duration(s1, NNG_OPT_RCVTIMEO, to) == 0); - So(nng_setopt_duration(s2, NNG_OPT_SNDTIMEO, to) == 0); - So(nng_setopt_duration(s2, NNG_OPT_RCVTIMEO, to) == 0); + So(nng_setopt_usec(s1, NNG_OPT_SNDTIMEO, to) == 0); + So(nng_setopt_usec(s1, NNG_OPT_RCVTIMEO, to) == 0); + So(nng_setopt_usec(s2, NNG_OPT_SNDTIMEO, to) == 0); + So(nng_setopt_usec(s2, NNG_OPT_RCVTIMEO, to) == 0); So(nng_listen(s1, a, NULL, 0) == 0); So(nng_dial(s2, a, NULL, 0) == 0); |
