From: Roy Marples Date: Thu, 24 Jul 2008 14:30:36 +0000 (+0000) Subject: get_time -> clock_monotonic to be more descriptive. X-Git-Tag: v4.0.2~134 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5fa0b31f1008b99c38637cbcccf8233b76e78b9b;p=thirdparty%2Fdhcpcd.git get_time -> clock_monotonic to be more descriptive. --- diff --git a/client.c b/client.c index f8b5e22a..e04af39f 100644 --- a/client.c +++ b/client.c @@ -453,7 +453,7 @@ get_old_lease(struct if_state *state) iface->start_uptime = uptime(); tv.tv_sec = lease->renewaltime - offset; tv.tv_usec = 0; - get_time(&state->timeout); + clock_monotonic(&state->timeout); timeradd(&state->timeout, &tv, &state->timeout); free(state->old); state->old = state->new; @@ -484,7 +484,7 @@ client_setup(struct if_state *state, const struct options *options) state->nakoff = 1; state->options = options->options; timerclear(&tv); - get_time(&state->start); + clock_monotonic(&state->start); if (options->request_address.s_addr == 0 && (options->options & DHCPCD_INFORM || @@ -743,7 +743,7 @@ wait_for_packet(struct if_state *state) } ref = NULL; - get_time(&now); + clock_monotonic(&now); if (timerisset(&state->exit)) { if (timercmp(&state->exit, &now, <=)) return 0; @@ -787,7 +787,7 @@ wait_for_packet(struct if_state *state) } wait_again: - get_time(&now); + clock_monotonic(&now); if (timeout == INFTIM) last_stop_sec = INFTIM; else { @@ -960,7 +960,7 @@ static int bind_dhcp(struct if_state *state, const struct options *options) tv.tv_sec = lease->renewaltime; tv.tv_usec = 0; - get_time(&state->stop); + clock_monotonic(&state->stop); timeradd(&state->stop, &tv, &state->stop); } state->state = STATE_BOUND; @@ -1090,7 +1090,7 @@ handle_timeout_fail(struct if_state *state, const struct options *options) state->state); } - get_time(&state->start); + clock_monotonic(&state->start); if (timerisset(&tv)) timeradd(&state->start, &tv, &state->stop); @@ -1109,7 +1109,7 @@ handle_timeout(struct if_state *state, const struct options *options) timerclear(&state->timeout); if (timerisset(&state->exit)) { - get_time(&tv); + clock_monotonic(&tv); if (timercmp(&tv, &state->exit, >)) return handle_timeout_fail(state, options); } @@ -1190,7 +1190,7 @@ handle_timeout(struct if_state *state, const struct options *options) iface->arp_fd = -1; tv.tv_sec = lease->renewaltime - (ANNOUNCE_INTERVAL * ANNOUNCE_NUM); - get_time(&state->stop); + clock_monotonic(&state->stop); timeradd(&state->stop, &tv, &state->stop); return 0; } @@ -1199,13 +1199,13 @@ handle_timeout(struct if_state *state, const struct options *options) } if (timerisset(&tv)) { timerclear(&state->stop); - get_time(&state->timeout); + clock_monotonic(&state->timeout); timeradd(&state->timeout, &tv, &state->timeout); return i; } if (timerisset(&state->stop)) { - get_time(&tv); + clock_monotonic(&tv); if (timercmp(&tv, &state->stop, >)) return handle_timeout_fail(state, options); } @@ -1214,7 +1214,7 @@ handle_timeout(struct if_state *state, const struct options *options) switch (state->state) { case STATE_BOUND: /* FALLTHROUGH */ case STATE_RENEW_REQUESTED: - get_time(&state->start); + clock_monotonic(&state->start); timerclear(&state->stop); /* FALLTHROUGH */ case STATE_INIT: @@ -1260,7 +1260,7 @@ handle_timeout(struct if_state *state, const struct options *options) if (!lease->addr.s_addr && !timerisset(&state->stop)) { tv.tv_sec = DHCP_MAX + DHCP_RAND_MIN; tv.tv_usec = arc4random() % (DHCP_RAND_MAX_U - DHCP_RAND_MIN_U); - get_time(&state->stop); + clock_monotonic(&state->stop); timeradd(&state->stop, &tv, &state->stop); } break; @@ -1287,7 +1287,7 @@ dhcp_timeout: timerclear(&state->timeout); return 0; } - get_time(&state->timeout); + clock_monotonic(&state->timeout); tv.tv_sec = DHCP_BASE; for (i = 1; i < state->messages; i++) { tv.tv_sec *= 2; @@ -1361,7 +1361,7 @@ handle_dhcp(struct if_state *state, struct dhcp_message **dhcpp, state->nakoff *= 2; if (state->nakoff > NAKOFF_MAX) state->nakoff = NAKOFF_MAX; - get_time(&state->timeout); + clock_monotonic(&state->timeout); timeradd(&state->timeout, &tv, &state->timeout); } return 0; @@ -1575,7 +1575,7 @@ handle_arp_fail(struct if_state *state, const struct options *options) send_message(state, DHCP_DECLINE, options); do_socket(state, SOCKET_CLOSED); state->state = STATE_INIT; - get_time(&state->timeout); + clock_monotonic(&state->timeout); tv.tv_sec = DHCP_ARP_FAIL; tv.tv_usec = 0; timeradd(&state->timeout, &tv, &state->timeout); @@ -1614,7 +1614,7 @@ handle_arp_fail(struct if_state *state, const struct options *options) state->state = STATE_INIT_IPV4LL; tv.tv_sec = PROBE_WAIT; tv.tv_usec = 0; - get_time(&state->timeout); + clock_monotonic(&state->timeout); timeradd(&state->timeout, &tv, &state->timeout); return 0; } diff --git a/common.c b/common.c index 8bc2b781..71095ebe 100644 --- a/common.c +++ b/common.c @@ -203,7 +203,7 @@ set_nonblock(int fd) * platforms. */ int -get_time(struct timeval *tp) +clock_monotonic(struct timeval *tp) { #if defined(_POSIX_MONOTONIC_CLOCK) && defined(CLOCK_MONOTONIC) struct timespec ts; @@ -232,11 +232,11 @@ get_time(struct timeval *tp) time_t uptime(void) { - struct timeval tp; + struct timeval tv; - if (get_time(&tp) == -1) + if (clock_monotonic(&tv) == -1) return -1; - return tp.tv_sec; + return tv.tv_sec; } int diff --git a/common.h b/common.h index dcbbf649..6836040a 100644 --- a/common.h +++ b/common.h @@ -76,7 +76,7 @@ int set_cloexec(int); int set_nonblock(int); int fd_hasdata(int); ssize_t get_line(char **, size_t *, FILE *); -int get_time(struct timeval *); +int clock_monotonic(struct timeval *); time_t uptime(void); int writepid(int, pid_t); void *xrealloc(void *, size_t);