summaryrefslogtreecommitdiff
path: root/accel-pppd/radius/stat_accm.c
diff options
context:
space:
mode:
authorKozlov Dmitry <dima@server>2011-08-19 14:04:55 +0400
committerKozlov Dmitry <dima@server>2011-08-19 14:04:55 +0400
commit5ef49162ea9763ca9878c22e3736766d8f1db014 (patch)
treef58da9adfc87ece6c608265fc694e66bd5db162c /accel-pppd/radius/stat_accm.c
parentfd52e4578dcc7de2301480fece9395563d643045 (diff)
downloadaccel-ppp-5ef49162ea9763ca9878c22e3736766d8f1db014.tar.gz
accel-ppp-5ef49162ea9763ca9878c22e3736766d8f1db014.zip
snmp support
Diffstat (limited to 'accel-pppd/radius/stat_accm.c')
-rw-r--r--accel-pppd/radius/stat_accm.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/accel-pppd/radius/stat_accm.c b/accel-pppd/radius/stat_accm.c
index 3de86fca..34935a15 100644
--- a/accel-pppd/radius/stat_accm.c
+++ b/accel-pppd/radius/stat_accm.c
@@ -38,11 +38,13 @@ struct stat_accm_t *stat_accm_create(unsigned int time)
static void stat_accm_clean(struct stat_accm_t *s)
{
struct item_t *it;
- time_t ts = time(NULL);
+ struct timespec ts;
+
+ clock_gettime(CLOCK_MONOTONIC, &ts);
while (!list_empty(&s->items)) {
it = list_entry(s->items.next, typeof(*it), entry);
- if (ts - it->ts > s->time) {
+ if (ts.tv_sec - it->ts > s->time) {
list_del(&it->entry);
--s->items_cnt;
s->total -= it->val;
@@ -55,13 +57,16 @@ static void stat_accm_clean(struct stat_accm_t *s)
void stat_accm_add(struct stat_accm_t *s, unsigned int val)
{
struct item_t *it;
+ struct timespec ts;
+
+ clock_gettime(CLOCK_MONOTONIC, &ts);
pthread_mutex_lock(&s->lock);
stat_accm_clean(s);
it = mempool_alloc(item_pool);
- it->ts = time(NULL);
+ it->ts = ts.tv_sec;
it->val = val;
list_add_tail(&it->entry, &s->items);
++s->items_cnt;