diff --git a/main/lock.c b/main/lock.c index b954977b1a83fff92ce044cd511facca2e690805..eef5d8621a98b8df3c8a031236cf66e749115ba1 100644 --- a/main/lock.c +++ b/main/lock.c @@ -1141,13 +1141,13 @@ int __ast_rwlock_timedrdlock(const char *filename, int line, const char *func, a res = pthread_rwlock_timedrdlock(&t->lock, abs_timeout); #else do { - struct timeval _start = ast_tvnow(), _diff; + struct timeval _now; for (;;) { if (!(res = pthread_rwlock_tryrdlock(&t->lock))) { break; } - _diff = ast_tvsub(ast_tvnow(), _start); - if (_diff.tv_sec > abs_timeout->tv_sec || (_diff.tv_sec == abs_timeout->tv_sec && _diff.tv_usec * 1000 > abs_timeout->tv_nsec)) { + _now = ast_tvnow(); + if (_now.tv_sec > abs_timeout->tv_sec || (_now.tv_sec == abs_timeout->tv_sec && _now.tv_usec * 1000 > abs_timeout->tv_nsec)) { break; } usleep(1); @@ -1244,13 +1244,13 @@ int __ast_rwlock_timedwrlock(const char *filename, int line, const char *func, a res = pthread_rwlock_timedwrlock(&t->lock, abs_timeout); #else do { - struct timeval _start = ast_tvnow(), _diff; + struct timeval _now; for (;;) { if (!(res = pthread_rwlock_trywrlock(&t->lock))) { break; } - _diff = ast_tvsub(ast_tvnow(), _start); - if (_diff.tv_sec > abs_timeout->tv_sec || (_diff.tv_sec == abs_timeout->tv_sec && _diff.tv_usec * 1000 > abs_timeout->tv_nsec)) { + _now = ast_tvnow(); + if (_now.tv_sec > abs_timeout->tv_sec || (_now.tv_sec == abs_timeout->tv_sec && _now.tv_usec * 1000 > abs_timeout->tv_nsec)) { break; } usleep(1);