summaryrefslogtreecommitdiff
path: root/main/lock.c
diff options
context:
space:
mode:
Diffstat (limited to 'main/lock.c')
-rw-r--r--main/lock.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/main/lock.c b/main/lock.c
index b954977b1..eef5d8621 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);