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:
parent
dabd865a5c
commit
ab4478587a
1 changed files with 6 additions and 3 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue