summaryrefslogtreecommitdiffstats
path: root/src/cache.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2009-08-21 16:06:08 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2009-08-21 16:06:08 +0200
commit58411110894c0a9e6a1a1ec9dbdf2fbe2ef3da00 (patch)
tree384477cd9a167103eedde5d0b0993cd1ac927092 /src/cache.c
parent3e6852f806c4368eda451b39f12b2ac2f2b5d33b (diff)
conntrackd: reduce the number of gettimeofday() syscalls
This patch reduces the number of gettimeofday syscalls by caching the current time in a variable at the beginning of the main loop. Based on a suggestion from Vincent Jardin. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/cache.c')
-rw-r--r--src/cache.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/cache.c b/src/cache.c
index ccdce86..74c5c4b 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -250,7 +250,7 @@ static int __add(struct cache *c, struct cache_object *obj, int id)
c->extra->add(obj, ((char *) obj) + c->extra_offset);
c->stats.active++;
- obj->lifetime = obj->lastupdate = time(NULL);
+ obj->lifetime = obj->lastupdate = time_cached();
obj->status = C_OBJ_NEW;
obj->refcnt++;
return 0;
@@ -288,7 +288,7 @@ void cache_update(struct cache *c, struct cache_object *obj, int id,
c->extra->update(obj, ((char *) obj) + c->extra_offset);
c->stats.upd_ok++;
- obj->lastupdate = time(NULL);
+ obj->lastupdate = time_cached();
obj->status = C_OBJ_ALIVE;
}