[svn-commits] russell: branch russell/ast_channel_ao2 r190213 - in /team/russell/ast_channe...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Apr 23 09:41:48 CDT 2009


Author: russell
Date: Thu Apr 23 09:41:41 2009
New Revision: 190213

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=190213
Log:
resolve, reset

Modified:
    team/russell/ast_channel_ao2/   (props changed)
    team/russell/ast_channel_ao2/configure
    team/russell/ast_channel_ao2/configure.ac
    team/russell/ast_channel_ao2/funcs/func_strings.c
    team/russell/ast_channel_ao2/include/asterisk/autoconfig.h.in
    team/russell/ast_channel_ao2/include/asterisk/lock.h

Propchange: team/russell/ast_channel_ao2/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/russell/ast_channel_ao2/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Thu Apr 23 09:41:41 2009
@@ -1,1 +1,1 @@
-/trunk:1-190083
+/trunk:1-190212

Modified: team/russell/ast_channel_ao2/configure.ac
URL: http://svn.digium.com/svn-view/asterisk/team/russell/ast_channel_ao2/configure.ac?view=diff&rev=190213&r1=190212&r2=190213
==============================================================================
--- team/russell/ast_channel_ao2/configure.ac (original)
+++ team/russell/ast_channel_ao2/configure.ac Thu Apr 23 09:41:41 2009
@@ -460,6 +460,24 @@
 AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1, [Define to 1 if your system defines PTHREAD_MUTEX_RECURSIVE_NP in pthread.h]),
 AC_MSG_RESULT(no)
 )
+
+AC_MSG_CHECKING(for pthread_rwlock_timedwrlock() in pthread.h)
+AC_LINK_IFELSE(
+  [AC_LANG_PROGRAM(
+    [#include <pthread.h>
+     #include <time.h>],
+    [pthread_rwlock_t foo; struct timespec bar; pthread_rwlock_timedwrlock(&foo, &bar)])
+  ],[
+    AC_MSG_RESULT(yes)
+    ac_cv_pthread_rwlock_timedwrlock="yes"
+  ],[
+    AC_MSG_RESULT(no)
+    ac_cv_pthread_rwlock_timedwrlock="no"
+  ]
+)
+if test "${ac_cv_pthread_rwlock_timedwrlock}" = "yes"; then
+  AC_DEFINE([HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK], 1, [Define if your system has pthread_rwlock_timedwrlock()])
+fi
 
 AST_C_DEFINE_CHECK([PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], [PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], [pthread.h])
 

Modified: team/russell/ast_channel_ao2/funcs/func_strings.c
URL: http://svn.digium.com/svn-view/asterisk/team/russell/ast_channel_ao2/funcs/func_strings.c?view=diff&rev=190213&r1=190212&r2=190213
==============================================================================
--- team/russell/ast_channel_ao2/funcs/func_strings.c (original)
+++ team/russell/ast_channel_ao2/funcs/func_strings.c Thu Apr 23 09:41:41 2009
@@ -282,7 +282,7 @@
 		<description>
 			<para>Example:</para>
 			<para>exten => s,1,Set(array=one,two,three)</para>
-			<para>exten => s,n,While($[${SET(var=${SHIFT(array)})}])</para>
+			<para>exten => s,n,While($["${SET(var=${SHIFT(array)})}" != ""])</para>
 			<para>exten => s,n,NoOp(var is ${var})</para>
 			<para>exten => s,n,EndWhile</para>
 			<para>This would iterate over each value in array, left to right, and
@@ -302,7 +302,7 @@
 		<description>
 			<para>Example:</para>
 			<para>exten => s,1,Set(array=one,two,three)</para>
-			<para>exten => s,n,While($[${SET(var=${POP(array)})}])</para>
+			<para>exten => s,n,While($["${SET(var=${POP(array)})}" != ""])</para>
 			<para>exten => s,n,NoOp(var is ${var})</para>
 			<para>exten => s,n,EndWhile</para>
 			<para>This would iterate over each value in array, right to left, and

Modified: team/russell/ast_channel_ao2/include/asterisk/autoconfig.h.in
URL: http://svn.digium.com/svn-view/asterisk/team/russell/ast_channel_ao2/include/asterisk/autoconfig.h.in?view=diff&rev=190213&r1=190212&r2=190213
==============================================================================
--- team/russell/ast_channel_ao2/include/asterisk/autoconfig.h.in (original)
+++ team/russell/ast_channel_ao2/include/asterisk/autoconfig.h.in Thu Apr 23 09:41:41 2009
@@ -715,6 +715,9 @@
 /* Define to 1 if your system defines PTHREAD_RWLOCK_PREFER_WRITER_NP in
    pthread.h */
 #undef HAVE_PTHREAD_RWLOCK_PREFER_WRITER_NP
+
+/* Define if your system has pthread_rwlock_timedwrlock() */
+#undef HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK
 
 /* Define to 1 if the system has the type `ptrdiff_t'. */
 #undef HAVE_PTRDIFF_T

Modified: team/russell/ast_channel_ao2/include/asterisk/lock.h
URL: http://svn.digium.com/svn-view/asterisk/team/russell/ast_channel_ao2/include/asterisk/lock.h?view=diff&rev=190213&r1=190212&r2=190213
==============================================================================
--- team/russell/ast_channel_ao2/include/asterisk/lock.h (original)
+++ team/russell/ast_channel_ao2/include/asterisk/lock.h Thu Apr 23 09:41:41 2009
@@ -49,9 +49,14 @@
 #define _ASTERISK_LOCK_H
 
 #include <pthread.h>
+#include <time.h>
 #include <sys/param.h>
 #ifdef HAVE_BKTR
 #include <execinfo.h>
+#endif
+
+#ifndef HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK
+#include "asterisk/time.h"
 #endif
 
 #include "asterisk/logger.h"
@@ -1397,7 +1402,23 @@
 		ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t);
 #endif
 	}
+#ifdef HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK
 	res = pthread_rwlock_timedrdlock(&t->lock, abs_timeout);
+#else
+	do {
+		struct timeval _start = ast_tvnow(), _diff;
+		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)) {
+				break;
+			}
+			usleep(1);
+		}
+	} while (0);
+#endif
 	if (!res) {
 		ast_reentrancy_lock(lt);
 		if (lt->reentrancy < AST_MAX_REENTRANCY) {
@@ -1476,7 +1497,23 @@
 		ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t);
 #endif
 	}
+#ifdef HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK
 	res = pthread_rwlock_timedwrlock(&t->lock, abs_timeout);
+#else
+	do {
+		struct timeval _start = ast_tvnow(), _diff;
+		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)) {
+				break;
+			}
+			usleep(1);
+		}
+	} while (0);
+#endif
 	if (!res) {
 		ast_reentrancy_lock(lt);
 		if (lt->reentrancy < AST_MAX_REENTRANCY) {
@@ -1764,7 +1801,23 @@
 
 static inline int ast_rwlock_timedrdlock(ast_rwlock_t *prwlock, const struct timespec *abs_timeout)
 {
-	return pthread_rwlock_timedrdlock(prwlock, abs_timeout);
+	int res;
+#ifdef HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK
+	res = pthread_rwlock_timedrdlock(prwlock, abs_timeout);
+#else
+	struct timeval _start = ast_tvnow(), _diff;
+	for (;;) {
+		if (!(res = pthread_rwlock_tryrdlock(prwlock))) {
+			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)) {
+			break;
+		}
+		usleep(1);
+	}
+#endif
+	return res;
 }
 
 static inline int ast_rwlock_tryrdlock(ast_rwlock_t *prwlock)
@@ -1779,7 +1832,25 @@
 
 static inline int ast_rwlock_timedwrlock(ast_rwlock_t *prwlock, const struct timespec *abs_timeout)
 {
-	return pthread_rwlock_timedwrlock(prwlock, abs_timeout);
+	int res;
+#ifdef HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK
+	res = pthread_rwlock_timedwrlock(prwlock, abs_timeout);
+#else
+	do {
+		struct timeval _start = ast_tvnow(), _diff;
+		for (;;) {
+			if (!(res = pthread_rwlock_trywrlock(prwlock))) {
+				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)) {
+				break;
+			}
+			usleep(1);
+		}
+	} while (0);
+#endif
+	return res;
 }
 
 static inline int ast_rwlock_trywrlock(ast_rwlock_t *prwlock)




More information about the svn-commits mailing list