This commit implements xnanosleep() for the threads needing high resolution sleep timeouts in windows.
CC: Alin Gabriel Serdean <[email protected]> CC: Aaron Conole <[email protected]> Signed-off-by: Bhanuprakash Bodireddy <[email protected]> --- lib/util.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/util.c b/lib/util.c index a29e288..46b5691 100644 --- a/lib/util.c +++ b/lib/util.c @@ -2217,6 +2217,23 @@ xnanosleep(uint64_t nanoseconds) retval = nanosleep(&ts_sleep, NULL); error = retval < 0 ? errno : 0; } while (error == EINTR); +#else + HANDLE timer = CreateWaitableTimer(NULL, FALSE, "NSTIMER"); + if (timer) { + LARGE_INTEGER duetime; + duetime.QuadPart = -nanoseconds; + if (SetWaitableTimer(timer, &duetime, 0, NULL, NULL, FALSE)) { + WaitForSingleObject(timer, INFINITE); + CloseHandle(timer); + } else { + CloseHandle(timer); + VLOG_ERR_ONCE("SetWaitableTimer Failed (%s)", + ovs_lasterror_to_string()); + } + } else { + VLOG_ERR_ONCE("CreateWaitableTimer Failed (%s)", + ovs_lasterror_to_string()); + } #endif ovsrcu_quiesce_end(); } -- 2.4.11 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
