use time_monotonic() instead of gettimeofday() for time difference calculations
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user