mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-17 00:07:04 -04:00
use CLOCK_REALTIME when CLOCK_MONOTONIC is not available; from Phil Oleson
svn:r290
This commit is contained in:
parent
c1aa5480de
commit
7fe5edf50c
6
evdns.c
6
evdns.c
@ -799,7 +799,11 @@ transaction_id_pick(void) {
|
|||||||
#ifdef DNS_USE_CPU_CLOCK_FOR_ID
|
#ifdef DNS_USE_CPU_CLOCK_FOR_ID
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
u16 trans_id;
|
u16 trans_id;
|
||||||
if (clock_gettime(CLOCK_MONOTONIC, &ts))
|
#ifdef CLOCK_MONOTONIC
|
||||||
|
if (clock_gettime(CLOCK_MONOTONIC, &ts) == -1)
|
||||||
|
#else
|
||||||
|
if (clock_gettime(CLOCK_REALTIME, &ts) == -1)
|
||||||
|
#endif
|
||||||
event_err(1, "clock_gettime");
|
event_err(1, "clock_gettime");
|
||||||
trans_id = ts.tv_nsec & 0xffff;
|
trans_id = ts.tv_nsec & 0xffff;
|
||||||
#endif
|
#endif
|
||||||
|
4
event.c
4
event.c
@ -150,7 +150,11 @@ gettime(struct timeval *tp)
|
|||||||
#ifdef HAVE_CLOCK_GETTIME
|
#ifdef HAVE_CLOCK_GETTIME
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
|
|
||||||
|
#ifdef HAVE_CLOCK_MONOTONIC
|
||||||
if (clock_gettime(CLOCK_MONOTONIC, &ts) == -1)
|
if (clock_gettime(CLOCK_MONOTONIC, &ts) == -1)
|
||||||
|
#else
|
||||||
|
if (clock_gettime(CLOCK_REALTIME, &ts) == -1)
|
||||||
|
#endif
|
||||||
return (-1);
|
return (-1);
|
||||||
tp->tv_sec = ts.tv_sec;
|
tp->tv_sec = ts.tv_sec;
|
||||||
tp->tv_usec = ts.tv_nsec / 1000;
|
tp->tv_usec = ts.tv_nsec / 1000;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user