Resolved timer/duration variable name TODO.
This commit is contained in:
parent
69000cda46
commit
25d4021269
|
@ -24,17 +24,17 @@ void testingprivRunWithTimeout(testingT *t, const char *file, long line, int64_t
|
|||
{
|
||||
char *timeoutstr;
|
||||
void (*prevsig)(int);
|
||||
struct itimerval timer, prevtimer;
|
||||
struct itimerval duration, prevDuration;
|
||||
int setitimerError = 0;
|
||||
|
||||
timeoutstr = testingNsecString(timeout);
|
||||
prevsig = signal(SIGALRM, onTimeout);
|
||||
|
||||
timer.it_interval.tv_sec = 0;
|
||||
timer.it_interval.tv_usec = 0;
|
||||
timer.it_value.tv_sec = timeout / testingNsecPerSec;
|
||||
timer.it_value.tv_usec = (timeout % testingNsecPerSec) / testingNsecPerUsec;
|
||||
if (setitimer(ITIMER_REAL, &timer, &prevtimer) != 0) {
|
||||
duration.it_interval.tv_sec = 0;
|
||||
duration.it_interval.tv_usec = 0;
|
||||
duration.it_value.tv_sec = timeout / testingNsecPerSec;
|
||||
duration.it_value.tv_usec = (timeout % testingNsecPerSec) / testingNsecPerUsec;
|
||||
if (setitimer(ITIMER_REAL, &duration, &prevDuration) != 0) {
|
||||
setitimerError = errno;
|
||||
testingprivTLogfFull(t, file, line, "error applying %s timeout: %s", comment, strerror(setitimerError));
|
||||
testingTFail(t);
|
||||
|
@ -51,7 +51,7 @@ void testingprivRunWithTimeout(testingT *t, const char *file, long line, int64_t
|
|||
|
||||
out:
|
||||
if (setitimerError == 0)
|
||||
setitimer(ITIMER_REAL, &prevtimer, NULL);
|
||||
setitimer(ITIMER_REAL, &prevDuration, NULL);
|
||||
signal(SIGALRM, prevsig);
|
||||
testingFreeNsecString(timeoutstr);
|
||||
if (failNowOnError)
|
||||
|
@ -60,12 +60,12 @@ out:
|
|||
|
||||
void testingSleep(int64_t nsec)
|
||||
{
|
||||
struct timespec rqtp;
|
||||
struct timespec duration;
|
||||
|
||||
// TODO check errors, possibly falling back to usleep, setitimer/pause, or even sleep
|
||||
rqtp.tv_sec = nsec / testingNsecPerSec;
|
||||
rqtp.tv_nsec = nsec % testingNsecPerSec;
|
||||
nanosleep(&rqtp, NULL);
|
||||
duration.tv_sec = nsec / testingNsecPerSec;
|
||||
duration.tv_nsec = nsec % testingNsecPerSec;
|
||||
nanosleep(&duration, NULL);
|
||||
}
|
||||
|
||||
struct testingThread {
|
||||
|
|
|
@ -300,7 +300,7 @@ void testingprivRunWithTimeout(testingT *t, const char *file, long line, int64_t
|
|||
MSG msg;
|
||||
int closeTargetThread = 0;
|
||||
uintptr_t timerThread = 0;
|
||||
LARGE_INTEGER timer;
|
||||
LARGE_INTEGER duration;
|
||||
int waitForTimerThread = 0;
|
||||
HRESULT hr;
|
||||
|
||||
|
@ -334,9 +334,9 @@ void testingprivRunWithTimeout(testingT *t, const char *file, long line, int64_t
|
|||
goto out;
|
||||
}
|
||||
|
||||
timer.QuadPart = timeout / 100;
|
||||
timer.QuadPart = -timer.QuadPart;
|
||||
hr = hrSetWaitableTimer(timeout_timer, &timer, 0, NULL, NULL, FALSE);
|
||||
duration.QuadPart = timeout / 100;
|
||||
duration.QuadPart = -duration.QuadPart;
|
||||
hr = hrSetWaitableTimer(timeout_timer, &duration, 0, NULL, NULL, FALSE);
|
||||
if (hr != S_OK) {
|
||||
testingprivTLogfFull(t, file, line, "error applying %s timeout: 0x%08I32X", comment, hr);
|
||||
testingTFail(t);
|
||||
|
@ -404,7 +404,6 @@ void testingSleep(int64_t nsec)
|
|||
LARGE_INTEGER duration;
|
||||
HRESULT hr;
|
||||
|
||||
// TODO rename all the other durations that are timeout or timer to duration or nsec, both here and in the Unix/Darwin code
|
||||
duration.QuadPart = nsec / 100;
|
||||
duration.QuadPart = -duration.QuadPart;
|
||||
hr = hrCreateWaitableTimerW(NULL, TRUE, NULL, &timer);
|
||||
|
|
Loading…
Reference in New Issue