preventing time backtracks even if the system
clock backtracks.
git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@789
e7ae566f-a301-0410-adde-
c780ea21d3b5
#include "memdbg.h"
volatile time_t now; /* GLOBAL */
+unsigned int now_adj = 0; /* GLOBAL */
/*
* Return a numerical string describing a struct timeval.
const char *tv_string_abs (const struct timeval *tv, struct gc_arena *gc);
extern volatile time_t now; /* updated frequently to time(NULL) */
+extern unsigned int now_adj;
static inline void
update_time (void)
{
- const time_t real_time = time (NULL);
+ const time_t real_time = time (NULL) + now_adj;
if (real_time > now)
now = real_time;
+ else if (real_time < now)
+ now_adj += (now - real_time);
}
static inline void