Use monotonic clock for relative time for eloop if available
Relative time shouldn't be calculated based on gettimeofday because that clock can jump (e.g., when the time is adjusted by the system administrator.) On systems where that is available, use CLOCK_BOOTTIME (on fairly recent Linux systems, this clock takes into account the time spend suspended) or CLOCK_MONOTONIC (on Linux and some POSIX systems, this clock is just freely running with no adjustments.) Reported-by: Holger Schurig <holgerschurig@gmail.com> Signed-hostap: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
parent
461e3ebe43
commit
594516b4c2
12 changed files with 184 additions and 62 deletions
|
@ -41,6 +41,17 @@ int os_get_time(struct os_time *t)
|
|||
}
|
||||
|
||||
|
||||
int os_get_reltime(struct os_reltime *t)
|
||||
{
|
||||
int res;
|
||||
struct timeval tv;
|
||||
res = gettimeofday(&tv, NULL);
|
||||
t->sec = tv.tv_sec;
|
||||
t->usec = tv.tv_usec;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
int os_mktime(int year, int month, int day, int hour, int min, int sec,
|
||||
os_time_t *t)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue