summaryrefslogtreecommitdiff
path: root/accel-pppd
diff options
context:
space:
mode:
authorKozlov Dmitry <xeb@mail.ru>2011-09-05 15:33:28 +0400
committerKozlov Dmitry <xeb@mail.ru>2011-09-05 15:33:28 +0400
commit8a0f7065300efbe6e916ec7e2a298dc8feec1298 (patch)
tree0c2d2931cbf1eedfac073f3ef11ae6aef683c127 /accel-pppd
parent3e6a720a2cbd08edb6d04255b2246a833df6825c (diff)
downloadaccel-ppp-8a0f7065300efbe6e916ec7e2a298dc8feec1298.tar.gz
accel-ppp-8a0f7065300efbe6e916ec7e2a298dc8feec1298.zip
radius: use clock_gettime(CLOCK_MONOTONIC) instead of gettimeofday
Diffstat (limited to 'accel-pppd')
-rw-r--r--accel-pppd/radius/acct.c6
-rw-r--r--accel-pppd/radius/auth.c10
-rw-r--r--accel-pppd/radius/packet.c4
-rw-r--r--accel-pppd/radius/radius.h2
4 files changed, 11 insertions, 11 deletions
diff --git a/accel-pppd/radius/acct.c b/accel-pppd/radius/acct.c
index 6f94861..a75eff4 100644
--- a/accel-pppd/radius/acct.c
+++ b/accel-pppd/radius/acct.c
@@ -102,7 +102,7 @@ static int rad_acct_read(struct triton_md_handler_t *h)
return 0;
dt = (req->reply->tv.tv_sec - req->pack->tv.tv_sec) * 1000 +
- (req->reply->tv.tv_usec - req->pack->tv.tv_usec) / 1000;
+ (req->reply->tv.tv_nsec - req->pack->tv.tv_nsec) / 1000000;
stat_accm_add(req->serv->stat_interim_query_1m, dt);
stat_accm_add(req->serv->stat_interim_query_5m, dt);
@@ -293,7 +293,7 @@ int rad_acct_start(struct radius_pd_t *rpd)
}
dt = (rpd->acct_req->reply->tv.tv_sec - rpd->acct_req->pack->tv.tv_sec) * 1000 +
- (rpd->acct_req->reply->tv.tv_usec - rpd->acct_req->pack->tv.tv_usec) / 1000;
+ (rpd->acct_req->reply->tv.tv_nsec - rpd->acct_req->pack->tv.tv_nsec) / 1000000;
stat_accm_add(rpd->acct_req->serv->stat_acct_query_1m, dt);
stat_accm_add(rpd->acct_req->serv->stat_acct_query_5m, dt);
@@ -433,7 +433,7 @@ void rad_acct_stop(struct radius_pd_t *rpd)
}
dt = (rpd->acct_req->reply->tv.tv_sec - rpd->acct_req->pack->tv.tv_sec) * 1000 +
- (rpd->acct_req->reply->tv.tv_usec - rpd->acct_req->pack->tv.tv_usec) / 1000;
+ (rpd->acct_req->reply->tv.tv_nsec - rpd->acct_req->pack->tv.tv_nsec) / 1000000;
stat_accm_add(rpd->acct_req->serv->stat_acct_query_1m, dt);
stat_accm_add(rpd->acct_req->serv->stat_acct_query_5m, dt);
diff --git a/accel-pppd/radius/auth.c b/accel-pppd/radius/auth.c
index c9f6655..becddf6 100644
--- a/accel-pppd/radius/auth.c
+++ b/accel-pppd/radius/auth.c
@@ -145,7 +145,7 @@ static uint8_t* encrypt_password(const char *passwd, const char *secret, const u
static int rad_auth_send(struct rad_req_t *req)
{
int i;
- struct timeval tv, tv2;
+ struct timespec tv, tv2;
unsigned int dt;
int timeout;
@@ -160,7 +160,7 @@ static int rad_auth_send(struct rad_req_t *req)
for(i = 0; i < conf_max_try; i++) {
__sync_add_and_fetch(&req->serv->stat_auth_sent, 1);
- gettimeofday(&tv, NULL);
+ clock_gettime(CLOCK_MONOTONIC, &tv);
if (rad_req_send(req, conf_verbose))
goto out;
@@ -174,8 +174,8 @@ static int rad_auth_send(struct rad_req_t *req)
if (req->reply->id != req->pack->id) {
rad_packet_free(req->reply);
req->reply = NULL;
- gettimeofday(&tv2, NULL);
- timeout = conf_timeout - ((tv2.tv_sec - tv.tv_sec) * 1000 + (tv2.tv_usec - tv.tv_usec) / 1000);
+ clock_gettime(CLOCK_MONOTONIC, &tv2);
+ timeout = conf_timeout - ((tv2.tv_sec - tv.tv_sec) * 1000 + (tv2.tv_nsec - tv.tv_nsec) / 1000000);
} else
break;
} else
@@ -183,7 +183,7 @@ static int rad_auth_send(struct rad_req_t *req)
}
if (req->reply) {
- dt = (req->reply->tv.tv_sec - tv.tv_sec) * 1000 + (req->reply->tv.tv_usec - tv.tv_usec) / 1000;
+ dt = (req->reply->tv.tv_sec - tv.tv_sec) * 1000 + (req->reply->tv.tv_nsec - tv.tv_nsec) / 1000000;
stat_accm_add(req->serv->stat_auth_query_1m, dt);
stat_accm_add(req->serv->stat_auth_query_5m, dt);
break;
diff --git a/accel-pppd/radius/packet.c b/accel-pppd/radius/packet.c
index 39541f7..5122067 100644
--- a/accel-pppd/radius/packet.c
+++ b/accel-pppd/radius/packet.c
@@ -135,7 +135,7 @@ int rad_packet_recv(int fd, struct rad_packet_t **p, struct sockaddr_in *addr)
}
pack->buf = ptr;
- gettimeofday(&pack->tv, NULL);
+ clock_gettime(CLOCK_MONOTONIC, &pack->tv);
while (1) {
if (addr)
@@ -736,7 +736,7 @@ int rad_packet_send(struct rad_packet_t *pack, int fd, struct sockaddr_in *addr)
{
int n;
- gettimeofday(&pack->tv, NULL);
+ clock_gettime(CLOCK_MONOTONIC, &pack->tv);
while (1) {
if (addr)
diff --git a/accel-pppd/radius/radius.h b/accel-pppd/radius/radius.h
index dd91efa..296fd13 100644
--- a/accel-pppd/radius/radius.h
+++ b/accel-pppd/radius/radius.h
@@ -90,7 +90,7 @@ struct rad_packet_t
int code;
uint8_t id;
int len;
- struct timeval tv;
+ struct timespec tv;
struct list_head attrs;
void *buf;
};