[svn-commits] dlee: trunk r371721 - in /trunk: ./ main/lock.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Aug 27 11:57:00 CDT 2012


Author: dlee
Date: Mon Aug 27 11:56:56 2012
New Revision: 371721

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=371721
Log:
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
........

Merged revisions 371720 from http://svn.asterisk.org/svn/asterisk/branches/11

Modified:
    trunk/   (props changed)
    trunk/main/lock.c

Propchange: trunk/
------------------------------------------------------------------------------
--- branch-11-merged (original)
+++ branch-11-merged Mon Aug 27 11:56:56 2012
@@ -1,1 +1,1 @@
-/branches/11:1-371121,371143,371146,371200,371227,371258,371272,371295,371324,371355,371382,371395,371399,371425-371426,371438,371482,371492,371507,371516,371518,371520,371546,371571,371592,371619,371664,371692
+/branches/11:1-371121,371143,371146,371200,371227,371258,371272,371295,371324,371355,371382,371395,371399,371425-371426,371438,371482,371492,371507,371516,371518,371520,371546,371571,371592,371619,371664,371692,371720

Modified: trunk/main/lock.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/lock.c?view=diff&rev=371721&r1=371720&r2=371721
==============================================================================
--- trunk/main/lock.c (original)
+++ trunk/main/lock.c Mon Aug 27 11:56:56 2012
@@ -1141,13 +1141,13 @@
 	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 @@
 	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);




More information about the svn-commits mailing list