18 Commits

Author SHA1 Message Date
Nick Grifka
a821914368 evutil_time: improve evutil_gettimeofday on Windows
If present, use GetSystemTimePreciseAsFileTime instead of
GetSystemTimeAsFileTime. Available since Windows 8.

(cherry picked from commit f0b3160f8ce7fbd411493dcd023f562f4f9d17ee)
2020-06-28 21:33:11 +03:00
yuangongji
d42240d1c6 evutil_time: Implements usleep() using wait funtion on Windows
(cherry picked from commit 6412f34f242e9b5b87f0378715baf97ba0bf1a8c)
2020-06-28 21:19:54 +03:00
yuangongji
f4a6152c3b evutil_time: detect and use _gmtime64_s()/_gmtime64()
(cherry picked from commit 148d12ad31b03a813f4ffd9df14a85392aa74130)
2020-06-28 21:17:33 +03:00
Azat Khuzhin
85fed75f7e
Replace all EVENT_HAVE with EVENT__HAVE (EVENT__HAVE_USLEEP)
(cherry picked from commit 35258a1f4e09d9e7fcb003cd0572343670180495)
2019-02-02 15:17:57 +03:00
Philip Prindeville
8818c86caf
Avoid possible SEGVs in select() (in unit tests)
Per the POSIX definition of select():

http://pubs.opengroup.org/onlinepubs/009696699/functions/pselect.html

"Upon successful completion, the select() function may modify the object
pointed to by the timout argument."

If "struct timeval" pointer is a "static const", it could potentially
be allocated in a RO text segment.  The kernel would then try to copy
back the modified value (with the time remaining) into a read-only
address and SEGV.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
Closes: #614
(cherry picked from commit 33baa4e59fbf9432d77a19c6b2b45402580b79a5)
2019-02-02 15:17:55 +03:00
Azat Khuzhin
4798de6c64 test: fix util/date_rfc1123 under win32
Refs: #417
v2: check when gmtime() returns NULL
v3: fix overflow cases
2016-12-22 18:10:24 +03:00
Azat Khuzhin
4545807db4 Fix UB in evutil_date_rfc1123()
As pointed in https://github.com/libevent/libevent/pull/417#issuecomment-267860738
  "code is unsafe because in evutil_date_rfc1123() the pointer to the
  automatic variable struct tm cur is used outside the scope it defined."

Checked with `clang -fsanitize=address -fsanitize-address-use-after-scope`
and test that call evutil_date_rfc1123() with tm==NULL
2016-12-22 14:46:38 +03:00
Vis Virial
db60ade81d http: do not use local settings for Date header 2016-12-19 00:55:50 +03:00
Azat Khuzhin
3e75194cb5 evutil_time: include <unistd.h> when there is only sleep()/usleep() 2016-12-06 12:54:05 +03:00
Andrea Shepard
f2645f80c1 Implement new/free for struct evutil_monotonic_timer and export monotonic time functions 2014-12-04 09:30:20 -05:00
Nick Mathewson
911abf3dd2 Check CLOCK_MONOTONIC_* at runtime if needed.
(We need this to avoid compile errors on cygwin.  Fixes github issue
75.)
2013-08-19 10:14:43 -04:00
Nick Mathewson
85a40040d1 Add regress_finalize to makefile.nmake 2013-05-01 13:37:57 -04:00
Nick Mathewson
9be546809a Avoid unused-var warning on systems with clock_gettime but without CLOCK_MONOTONIC_COARSE 2012-08-02 12:35:49 -04:00
Nick Mathewson
630f077c29 Simple unit tests for monotonic timers 2012-04-26 16:42:21 -04:00
Nick Mathewson
2c470452fb Implement fast/precise monotonic clocks on Windows
This uses code from libutp, which was released under the MIT
license; see evutil_time.c and LICENSE changes.
2012-04-26 15:44:37 -04:00
Nick Mathewson
f5e4eb05e5 Refactor monotonic timer handling into a new type and set of functions; add a gettimeofday-based ratcheting implementation
Now, event.c can always assume that we have a monotonic timer; this
makes event.c easier to write.
2012-04-26 15:44:31 -04:00
Nick Mathewson
71bca50f12 Split out time-related prototypes into time-internal.h 2012-04-20 12:27:12 -04:00
Nick Mathewson
c419485442 Split out time-related evutil functions into a new evutil_time.c 2012-04-20 12:19:03 -04:00