1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

logs: avoid monotonic time

lws_now_usecs() uses monotonic time now.  It's not sync'd with
wallclock time and the two can't be mixed.  Switch to
gettimeofday which is nonmonotonic and use also for fractional
time to avoid fractional secs in logs being unrelated to integer
seconds boundary.
This commit is contained in:
Andy Green 2019-09-22 04:06:03 -07:00
parent dabd865a5c
commit ab4478587a

View file

@ -63,16 +63,19 @@ LWS_VISIBLE int
lwsl_timestamp(int level, char *p, int len)
{
#ifndef LWS_PLAT_OPTEE
#ifndef _WIN32_WCE
time_t o_now = time(NULL);
#endif
time_t o_now;
unsigned long long now;
struct timeval tv;
struct tm *ptm = NULL;
#ifndef WIN32
struct tm tm;
#endif
int n;
gettimeofday(&tv, NULL);
o_now = tv.tv_sec;
now = ((unsigned long long)tv.tv_sec * 10000) + (tv.tv_usec / 100);
#ifndef _WIN32_WCE
#ifdef WIN32
ptm = localtime(&o_now);