aboutsummaryrefslogtreecommitdiff
path: root/otime.h
diff options
context:
space:
mode:
authorjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2005-11-09 10:03:50 +0000
committerjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2005-11-09 10:03:50 +0000
commitba2ebecbedee53f00575b607e0a6c873b97ca4d1 (patch)
treeea75194afca59713e2f0ad866a76a909f467af74 /otime.h
parentupdated version number to 2.1_beta7 (diff)
downloadopenvpn-ba2ebecbedee53f00575b607e0a6c873b97ca4d1.tar.xz
Fixed update_time to use a better algorithm for
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
Diffstat (limited to 'otime.h')
-rw-r--r--otime.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/otime.h b/otime.h
index 0026646..09a85c7 100644
--- a/otime.h
+++ b/otime.h
@@ -55,13 +55,16 @@ const char *tv_string (const struct timeval *tv, struct gc_arena *gc);
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