detect CLOCK_MONOTONIC at runtime for evdns

svn:r896
This commit is contained in:
Niels Provos 2008-07-02 04:39:09 +00:00
parent 707f67849a
commit 409236a77d
2 changed files with 9 additions and 4 deletions

View File

@ -114,6 +114,7 @@ Changes in current version:
o Correct handling of trailing headers in chunked replies; from Scott Lamb.
o Support multi-line HTTP headers; based on a patch from Moshe Litvin
o Reject negative Content-Length headers; anonymous bug report
o Detect CLOCK_MONOTONIC at runtime for evdns; anonymous bug report
Changes in 1.4.0:
o allow \r or \n individually to separate HTTP headers instead of the standard "\r\n"; from Charles Kerr.

12
evdns.c
View File

@ -1056,12 +1056,16 @@ default_transaction_id_fn(void)
u16 trans_id;
#ifdef DNS_USE_CPU_CLOCK_FOR_ID
struct timespec ts;
static int clkid = -1;
if (clkid == -1) {
clkid = CLOCK_REALTIME;
#ifdef CLOCK_MONOTONIC
if (clock_gettime(CLOCK_MONOTONIC, &ts) == -1)
#else
if (clock_gettime(CLOCK_REALTIME, &ts) == -1)
if (clock_gettime(CLOCK_MONOTONIC, &ts) != -1)
clkid = CLOCK_MONOTONIC;
#endif
event_err(1, "clock_gettime");
}
if (clock_gettime(clkid, &ts) == -1)
event_err(1, "clock_gettime");
trans_id = ts.tv_nsec & 0xffff;
#endif