From 58411110894c0a9e6a1a1ec9dbdf2fbe2ef3da00 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Fri, 21 Aug 2009 16:06:08 +0200 Subject: 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 --- include/Makefile.am | 2 +- include/cache.h | 1 + include/date.h | 10 ++++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 include/date.h (limited to 'include') diff --git a/include/Makefile.am b/include/Makefile.am index 0fa76af..844c5b8 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -4,5 +4,5 @@ noinst_HEADERS = alarm.h jhash.h cache.h linux_list.h linux_rbtree.h \ debug.h log.h hash.h mcast.h conntrack.h \ network.h filter.h queue.h vector.h cidr.h \ traffic_stats.h netlink.h fds.h event.h bitops.h channel.h \ - process.h origin.h external.h + process.h origin.h external.h date.h diff --git a/include/cache.h b/include/cache.h index 7e61085..28917f2 100644 --- a/include/cache.h +++ b/include/cache.h @@ -4,6 +4,7 @@ #include #include #include "hash.h" +#include "date.h" /* cache features */ enum { diff --git a/include/date.h b/include/date.h new file mode 100644 index 0000000..296b996 --- /dev/null +++ b/include/date.h @@ -0,0 +1,10 @@ +#ifndef _DATE_H_ +#define _DATE_H_ + +#include + +int do_gettimeofday(void); +void gettimeofday_cached(struct timeval *tv); +int time_cached(void); + +#endif -- cgit v1.2.3