diff options
author | Martin Willi <martin@strongswan.org> | 2009-08-31 15:25:03 +0200 |
---|---|---|
committer | Martin Willi <martin@strongswan.org> | 2009-08-31 15:25:03 +0200 |
commit | de5784452b31af3c7342269127a12d352edc0b4e (patch) | |
tree | 04fc6c8bcb9ca117a5d09171651c4e91fae70666 /src/charon/plugins/kernel_netlink/kernel_netlink_net.c | |
parent | 3d5818ec38c464b24f382d88c70b10df6c04b160 (diff) | |
download | strongswan-de5784452b31af3c7342269127a12d352edc0b4e.tar.bz2 strongswan-de5784452b31af3c7342269127a12d352edc0b4e.tar.xz |
use time_monotonic() instead of gettimeofday() for time difference calculations
Diffstat (limited to 'src/charon/plugins/kernel_netlink/kernel_netlink_net.c')
-rw-r--r-- | src/charon/plugins/kernel_netlink/kernel_netlink_net.c | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/src/charon/plugins/kernel_netlink/kernel_netlink_net.c b/src/charon/plugins/kernel_netlink/kernel_netlink_net.c index e5c0b5da7..fd79f0781 100644 --- a/src/charon/plugins/kernel_netlink/kernel_netlink_net.c +++ b/src/charon/plugins/kernel_netlink/kernel_netlink_net.c @@ -17,7 +17,6 @@ #include <sys/socket.h> #include <linux/netlink.h> #include <linux/rtnetlink.h> -#include <sys/time.h> #include <pthread.h> #include <unistd.h> #include <errno.h> @@ -145,7 +144,7 @@ struct private_kernel_netlink_net_t { /** * time of the last roam_job */ - struct timeval last_roam; + timeval_t last_roam; /** * routing table to install routes @@ -208,22 +207,20 @@ static int get_vip_refcount(private_kernel_netlink_net_t *this, host_t* ip) */ static void fire_roam_job(private_kernel_netlink_net_t *this, bool address) { - struct timeval now; + timeval_t now; - if (gettimeofday(&now, NULL) == 0) + time_monotonic(&now); + if (timercmp(&now, &this->last_roam, >)) { - if (timercmp(&now, &this->last_roam, >)) + now.tv_usec += ROAM_DELAY * 1000; + while (now.tv_usec > 1000000) { - now.tv_usec += ROAM_DELAY * 1000; - while (now.tv_usec > 1000000) - { - now.tv_sec++; - now.tv_usec -= 1000000; - } - this->last_roam = now; - charon->scheduler->schedule_job_ms(charon->scheduler, - (job_t*)roam_job_create(address), ROAM_DELAY); + now.tv_sec++; + now.tv_usec -= 1000000; } + this->last_roam = now; + charon->scheduler->schedule_job_ms(charon->scheduler, + (job_t*)roam_job_create(address), ROAM_DELAY); } } |