From b47a223bfb2c7114154504ec8d6cdac5abd0b884 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Mon, 14 Aug 2017 21:58:02 -0700 Subject: Convert duration to usec. --- src/core/options.c | 4 ++-- src/core/options.h | 4 ++-- src/core/socket.c | 26 ++++++++++---------------- src/core/socket.h | 5 ++--- 4 files changed, 16 insertions(+), 23 deletions(-) (limited to 'src/core') 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 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 -- cgit v1.2.3-70-g09d2