diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2014-10-03 21:59:07 +0400 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2014-10-03 21:59:07 +0400 |
commit | 9994d48250e3805565f709d39ea0de4877436c6c (patch) | |
tree | 23ef90295715bb672a80da7fb1c7f9614cb2375e /accel-pppd | |
parent | 8a7290359a446ce04c468b2a598ca75a6e2a9611 (diff) | |
download | accel-ppp-9994d48250e3805565f709d39ea0de4877436c6c.tar.gz accel-ppp-9994d48250e3805565f709d39ea0de4877436c6c.zip |
get rid of time(), use clock_gettime(CLOCK_MONOTONIC) instead
Diffstat (limited to 'accel-pppd')
-rw-r--r-- | accel-pppd/cli/show_sessions.c | 2 | ||||
-rw-r--r-- | accel-pppd/extra/net-snmp/sessionTable_data_access.c | 5 | ||||
-rw-r--r-- | accel-pppd/ppp/ppp_lcp.c | 4 | ||||
-rw-r--r-- | accel-pppd/radius/acct.c | 2 | ||||
-rw-r--r-- | accel-pppd/radius/radius.c | 7 | ||||
-rw-r--r-- | accel-pppd/session.c | 6 | ||||
-rw-r--r-- | accel-pppd/triton/log.c | 1 | ||||
-rw-r--r-- | accel-pppd/triton/triton.h | 8 |
8 files changed, 18 insertions, 17 deletions
diff --git a/accel-pppd/cli/show_sessions.c b/accel-pppd/cli/show_sessions.c index 13f1a831..84ccb70b 100644 --- a/accel-pppd/cli/show_sessions.c +++ b/accel-pppd/cli/show_sessions.c @@ -425,7 +425,7 @@ static void print_uptime(const struct ap_session *ses, char *buf) if (ses->stop_time) uptime = ses->stop_time - ses->start_time; else { - time(&uptime); + uptime = _time(); uptime -= ses->start_time; } diff --git a/accel-pppd/extra/net-snmp/sessionTable_data_access.c b/accel-pppd/extra/net-snmp/sessionTable_data_access.c index 5eb0dd33..ac7e94af 100644 --- a/accel-pppd/extra/net-snmp/sessionTable_data_access.c +++ b/accel-pppd/extra/net-snmp/sessionTable_data_access.c @@ -199,9 +199,6 @@ sessionTable_container_load(netsnmp_container *container) sessionTable_rowreq_ctx *rowreq_ctx; size_t count = 0; struct ap_session *ses; - time_t t; - - time(&t); DEBUGMSGTL(("verbose:sessionTable:sessionTable_container_load","called\n")); @@ -232,7 +229,7 @@ sessionTable_container_load(netsnmp_container *container) rowreq_ctx->data->peer_addr = ses->ipv4 ? ses->ipv4->peer_addr : 0; rowreq_ctx->data->type = ses->ctrl->type; rowreq_ctx->data->state = ses->state; - rowreq_ctx->data->uptime = (ses->stop_time ? ses->stop_time : t) - ses->start_time; + rowreq_ctx->data->uptime = (ses->stop_time ? ses->stop_time : _time()) - ses->start_time; rowreq_ctx->data->calling_sid = _strdup(ses->ctrl->calling_station_id); rowreq_ctx->data->called_sid = _strdup(ses->ctrl->called_station_id); diff --git a/accel-pppd/ppp/ppp_lcp.c b/accel-pppd/ppp/ppp_lcp.c index 54826efc..3dd8708b 100644 --- a/accel-pppd/ppp/ppp_lcp.c +++ b/accel-pppd/ppp/ppp_lcp.c @@ -661,9 +661,9 @@ static void send_echo_request(struct triton_timer_t *t) if (conf_echo_timeout) { if (lcp->echo_sent == 2) { lcp->last_ipackets = stats.rx_packets; - time(&lcp->last_echo_ts); + lcp->last_echo_ts = _time(); } else if (lcp->echo_sent > 2) { - time(&ts); + ts = _time(); if (lcp->last_ipackets != stats.rx_packets) { lcp->echo_sent = 1; lcp_update_echo_timer(lcp); diff --git a/accel-pppd/radius/acct.c b/accel-pppd/radius/acct.c index f9919453..c4b37cd5 100644 --- a/accel-pppd/radius/acct.c +++ b/accel-pppd/radius/acct.c @@ -161,7 +161,7 @@ static void rad_acct_interim_update(struct triton_timer_t *t) return; if (rpd->session_timeout.expire_tv.tv_sec && - rpd->session_timeout.expire_tv.tv_sec - (time(NULL) - rpd->ses->start_time) < INTERIM_SAFE_TIME) + rpd->session_timeout.expire_tv.tv_sec - (_time() - rpd->ses->start_time) < INTERIM_SAFE_TIME) return; if (req_set_stat(rpd->acct_req, rpd->ses)) { diff --git a/accel-pppd/radius/radius.c b/accel-pppd/radius/radius.c index c94769c5..fa2b6a64 100644 --- a/accel-pppd/radius/radius.c +++ b/accel-pppd/radius/radius.c @@ -277,16 +277,13 @@ static void session_timeout(struct triton_timer_t *t) static void idle_timeout(struct triton_timer_t *t) { struct radius_pd_t *rpd = container_of(t, typeof(*rpd), idle_timeout); - time_t tt; - + if (rpd->ses->stop_time) return; - time(&tt); - ap_session_read_stats(rpd->ses, NULL); - if (tt - rpd->ses->idle_time > t->period / 1000) { + if (_time() - rpd->ses->idle_time > t->period / 1000) { log_ppp_msg("radius: idle timed out\n"); ap_session_terminate(rpd->ses, TERM_IDLE_TIMEOUT, 0); } diff --git a/accel-pppd/session.c b/accel-pppd/session.c index 8fc61459..b50686cd 100644 --- a/accel-pppd/session.c +++ b/accel-pppd/session.c @@ -98,7 +98,7 @@ int __export ap_session_starting(struct ap_session *ses) ap_session_set_ifindex(ses); if (ses->state != AP_STATE_RESTORE) { - ses->start_time = time(NULL); + ses->start_time = _time(); ses->idle_time = ses->start_time; generate_sessionid(ses); @@ -204,7 +204,7 @@ void __export ap_session_terminate(struct ap_session *ses, int cause, int hard) return; if (!ses->stop_time) - time(&ses->stop_time); + ses->stop_time = _time(); if (!ses->terminate_cause) ses->terminate_cause = cause; @@ -303,7 +303,7 @@ int __export ap_session_read_stats(struct ap_session *ses, struct rtnl_link_stat stats->tx_bytes -= ses->acct_tx_bytes_i; if (stats->rx_bytes != ses->acct_rx_bytes || stats->tx_bytes != ses->acct_tx_bytes) - time(&ses->idle_time); + ses->idle_time = _time(); if (stats->rx_bytes < ses->acct_rx_bytes) ses->acct_input_gigawords++; diff --git a/accel-pppd/triton/log.c b/accel-pppd/triton/log.c index 9226e117..668d9e92 100644 --- a/accel-pppd/triton/log.c +++ b/accel-pppd/triton/log.c @@ -1,5 +1,6 @@ #include <stdio.h> #include <stdarg.h> +#include <sys/time.h> #include "triton_p.h" diff --git a/accel-pppd/triton/triton.h b/accel-pppd/triton/triton.h index af42a19d..3c02db2e 100644 --- a/accel-pppd/triton/triton.h +++ b/accel-pppd/triton/triton.h @@ -1,7 +1,7 @@ #ifndef TRITON_H #define TRITON_H -#include <sys/time.h> +#include <time.h> #include <stdint.h> #include "list.h" @@ -110,6 +110,12 @@ int triton_module_loaded(const char *name); void triton_register_init(int order, void (*func)(void)); +static inline time_t _time() +{ + struct timespec ts; + clock_gettime(CLOCK_MONOTONIC, &ts); + return ts.tv_sec; +} #define TRITON_OK 0 #define TRITON_ERR_NOCOMP -1 |