]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 371719 via svnmerge from
authorAutomerge script <automerge@asterisk.org>
Mon, 27 Aug 2012 17:24:42 +0000 (17:24 +0000)
committerAutomerge script <automerge@asterisk.org>
Mon, 27 Aug 2012 17:24:42 +0000 (17:24 +0000)
file:///srv/subversion/repos/asterisk/branches/10

................
  r371719 | dlee | 2012-08-27 11:43:09 -0500 (Mon, 27 Aug 2012) | 15 lines

  Fixes ast_rwlock_timed[rd|wr]lock for BSD and variants.

  The original implementations simply wrap pthread functions, which take
  absolute time as an argument. The spinlock version for systems without
  those functions treated the argument as a delta. This patch fixes the
  spinlock version to be consistent with the pthread version.

  (closes issue ASTERISK-20240)
  Reported by: Egor Gorlin
  Patches:
   lock.c.patch uploaded by Egor Gorlin (license 6416)
  ........

  Merged revisions 371718 from http://svn.asterisk.org/svn/asterisk/branches/1.8
................

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/10-digiumphones@371746 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/lock.c

index c854b3d615128743a0532b93cf76b688d66da4b7..c48c71e7c95601a4b1ba29c3a7e074613f4feb9c 100644 (file)
@@ -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);