fix condition_variable wait
Some checks failed
rpcrypto-build / build (Debug, himix200.toolchain.cmake) (push) Successful in 1m14s
rpcrypto-build / build (Release, hisiv510.toolchain.cmake) (push) Successful in 1m12s
rpcrypto-build / build (Release, himix200.toolchain.cmake) (push) Successful in 1m15s
linux-hisiv500-gcc / linux-gcc-hisiv500 (push) Successful in 1m24s
rpcrypto-build / build (Debug, hisiv510.toolchain.cmake) (push) Successful in 1m33s
linux-x64-gcc / linux-gcc (push) Has been cancelled
linux-mips64-gcc / linux-gcc-mips64el (push) Has been cancelled

This commit is contained in:
tqcq 2024-03-05 13:18:57 +08:00
parent 64780c4bb1
commit ae88a7e4fb
2 changed files with 4 additions and 4 deletions

View File

@ -36,8 +36,8 @@ public:
bool WaitForMilliseconds(MutexImpl &mutex_impl, uint32_t wait_time) bool WaitForMilliseconds(MutexImpl &mutex_impl, uint32_t wait_time)
{ {
struct timespec ts; struct timespec ts;
ts.tv_sec = 0; ts.tv_sec = wait_time / 1000;
ts.tv_nsec = wait_time * 1000000; ts.tv_nsec = (wait_time % 1000) * 1000000;
return ETIMEDOUT != pthread_cond_timedwait(&cond_, &mutex_impl.mutex_, &ts); return ETIMEDOUT != pthread_cond_timedwait(&cond_, &mutex_impl.mutex_, &ts);
} }

View File

@ -130,7 +130,7 @@ TimerManager::Loop()
uint64_t wait_time_ms = (timers_.begin()->first - now + 1000) / 1000; uint64_t wait_time_ms = (timers_.begin()->first - now + 1000) / 1000;
// FIX: // FIX:
if (wait_time_ms == 0) { wait_time_ms = 1; } if (wait_time_ms < 100) { wait_time_ms = 100; }
timers_cond_.WaitForMilliseconds(timers_guard, wait_time_ms); timers_cond_.WaitForMilliseconds(timers_guard, wait_time_ms);
now = TimeNowInMicroSeconds(); now = TimeNowInMicroSeconds();