Fix time handling in cv_timedwait_hires().
pthread_cond_timedwait() receives absolute time, not relative. Passing wrong time there caused two threads of zdb to spin in a tight loop. MFC after: 1 week
This commit is contained in:
parent
ca1578f0c0
commit
c9bcbf3800
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=318516
@ -368,7 +368,7 @@ cv_timedwait_hires(kcondvar_t *cv, kmutex_t *mp, hrtime_t tim, hrtime_t res,
|
|||||||
int flag)
|
int flag)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
timestruc_t ts;
|
timespec_t ts;
|
||||||
hrtime_t delta;
|
hrtime_t delta;
|
||||||
|
|
||||||
ASSERT(flag == 0 || flag == CALLOUT_FLAG_ABSOLUTE);
|
ASSERT(flag == 0 || flag == CALLOUT_FLAG_ABSOLUTE);
|
||||||
@ -381,8 +381,13 @@ cv_timedwait_hires(kcondvar_t *cv, kmutex_t *mp, hrtime_t tim, hrtime_t res,
|
|||||||
if (delta <= 0)
|
if (delta <= 0)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
ts.tv_sec = delta / NANOSEC;
|
clock_gettime(CLOCK_REALTIME, &ts);
|
||||||
ts.tv_nsec = delta % NANOSEC;
|
ts.tv_sec += delta / NANOSEC;
|
||||||
|
ts.tv_nsec += delta % NANOSEC;
|
||||||
|
if (ts.tv_nsec >= NANOSEC) {
|
||||||
|
ts.tv_sec++;
|
||||||
|
ts.tv_nsec -= NANOSEC;
|
||||||
|
}
|
||||||
|
|
||||||
ASSERT(mutex_owner(mp) == curthread);
|
ASSERT(mutex_owner(mp) == curthread);
|
||||||
mp->m_owner = NULL;
|
mp->m_owner = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user