[asterisk-commits] russell: branch russell/chan_refcount r89502 - in /team/russell/chan_refcount...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Nov 21 13:55:16 CST 2007


Author: russell
Date: Wed Nov 21 13:55:15 2007
New Revision: 89502

URL: http://svn.digium.com/view/asterisk?view=rev&rev=89502
Log:
sync up some more, and resolve conflicts

Modified:
    team/russell/chan_refcount/   (props changed)
    team/russell/chan_refcount/Makefile
    team/russell/chan_refcount/Makefile.moddir_rules
    team/russell/chan_refcount/channels/Makefile
    team/russell/chan_refcount/channels/busy.h
    team/russell/chan_refcount/channels/chan_agent.c
    team/russell/chan_refcount/channels/chan_sip.c
    team/russell/chan_refcount/channels/chan_zap.c
    team/russell/chan_refcount/channels/ringtone.h
    team/russell/chan_refcount/configs/zapata.conf.sample
    team/russell/chan_refcount/configure
    team/russell/chan_refcount/configure.ac
    team/russell/chan_refcount/include/asterisk/autoconfig.h.in
    team/russell/chan_refcount/include/asterisk/lock.h
    team/russell/chan_refcount/include/asterisk/pbx.h
    team/russell/chan_refcount/include/asterisk/srv.h
    team/russell/chan_refcount/main/Makefile
    team/russell/chan_refcount/main/channel.c
    team/russell/chan_refcount/main/pbx.c
    team/russell/chan_refcount/utils/Makefile

Propchange: team/russell/chan_refcount/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/russell/chan_refcount/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Nov 21 13:55:15 2007
@@ -1,1 +1,1 @@
-/trunk:1-88750
+/trunk:1-89000

Modified: team/russell/chan_refcount/Makefile
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/Makefile?view=diff&rev=89502&r1=89501&r2=89502
==============================================================================
--- team/russell/chan_refcount/Makefile (original)
+++ team/russell/chan_refcount/Makefile Wed Nov 21 13:55:15 2007
@@ -15,7 +15,6 @@
 #
 # ASTCFLAGS - compiler options
 # ASTLDFLAGS - linker flags (not libraries)
-# AST_LIBS - libraries to build binaries XXX
 # LIBS - additional libraries, at top-level for all links,
 #      on a single object just for that object
 # SOLINK - linker flags used only for creating shared objects (.so files),
@@ -62,12 +61,6 @@
 export GREP
 export ID
 export OSARCH
-export CURSES_DIR
-export NCURSES_DIR
-export TERMCAP_DIR
-export TINFO_DIR
-export GTK2_LIB
-export GTK2_INCLUDE
 
 # even though we could use '-include makeopts' here, use a wildcard
 # lookup anyway, so that make won't try to build makeopts if it doesn't
@@ -229,7 +222,6 @@
   # -V is understood by BSD Make, not by GNU make.
   BSDVERSION=$(shell make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk)
   ASTCFLAGS+=$(shell if test $(BSDVERSION) -lt 500016 ; then echo "-D_THREAD_SAFE"; fi)
-  AST_LIBS+=$(shell if test  $(BSDVERSION) -lt 502102 ; then echo "-lc_r"; else echo "-pthread"; fi)
 endif
 
 ifeq ($(OSARCH),NetBSD)
@@ -272,7 +264,6 @@
 
 ifneq ($(findstring darwin,$(OSARCH)),)
   ASTCFLAGS+=-D__Darwin__
-  AUDIO_LIBS=-framework CoreAudio
   SOLINK=-dynamic -bundle -undefined suppress -force_flat_namespace
 else
 # These are used for all but Darwin
@@ -348,12 +339,12 @@
 
 $(MOD_SUBDIRS):
 	@echo "   [enter MOD_SUBDIR $@/]"
-	@ASTCFLAGS="$(MOD_SUBDIR_CFLAGS) $(ASTCFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" AST_LIBS="$(AST_LIBS)" $(MAKE) --no-print-directory --no-builtin-rules -C $@ SUBDIR=$@ all
+	@ASTCFLAGS="$(MOD_SUBDIR_CFLAGS) $(ASTCFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(MAKE) --no-print-directory --no-builtin-rules -C $@ SUBDIR=$@ all
 	@echo "   [exit MOD_SUBDIR $@/]"
 
 $(OTHER_SUBDIRS):
 	@echo "   [enter SUBDIR $@/]"
-	@ASTCFLAGS="$(OTHER_SUBDIR_CFLAGS) $(ASTCFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" AUDIO_LIBS="$(AUDIO_LIBS)" $(MAKE) --no-print-directory --no-builtin-rules -C $@ SUBDIR=$@ all
+	@ASTCFLAGS="$(OTHER_SUBDIR_CFLAGS) $(ASTCFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(MAKE) --no-print-directory --no-builtin-rules -C $@ SUBDIR=$@ all
 	@echo "   [exit SUBDIR $@/]"
 
 defaults.h: makeopts

Modified: team/russell/chan_refcount/Makefile.moddir_rules
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/Makefile.moddir_rules?view=diff&rev=89502&r1=89501&r2=89502
==============================================================================
--- team/russell/chan_refcount/Makefile.moddir_rules (original)
+++ team/russell/chan_refcount/Makefile.moddir_rules Wed Nov 21 13:55:15 2007
@@ -34,7 +34,7 @@
 
 include $(ASTTOPDIR)/Makefile.rules
 
-comma:=,
+#comma:=,	# not used
 
 # Both C++ and C++ sources need their module name in AST_MODULE
 # We also pass whatever _INCLUDE list is generated by menuselect

Modified: team/russell/chan_refcount/channels/Makefile
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/channels/Makefile?view=diff&rev=89502&r1=89501&r2=89502
==============================================================================
--- team/russell/chan_refcount/channels/Makefile (original)
+++ team/russell/chan_refcount/channels/Makefile Wed Nov 21 13:55:15 2007
@@ -83,15 +83,15 @@
 dist-clean::
 	rm -f h323/Makefile
 
+# gentone must be built with the HOST environment
 gentone: gentone.c
-	$(ECHO_PREFIX) echo "   [LD] $^ -> $@"
-	$(CMD_PREFIX) $(HOST_CC) $(STATIC_BUILD) -o $@ $(HOST_CFLAGS) $(HOST_LDFLAGS) $^ $(LIBS)
-gentone: LIBS+=-lm
+	$(ECHO_PREFIX) echo "   [HOST_CC] $^ -> $@"
+	$(CMD_PREFIX) $(HOST_CC) -o $@ $^ -lm
 
-busy.h:
+busy.h: gentone
 	./gentone busy 480 620
 
-ringtone.h:
+ringtone.h: gentone
 	./gentone ringtone 440 480
 
 $(if $(filter chan_iax2,$(EMBEDDED_MODS)),modules.link,chan_iax2.so): iax2-parser.o iax2-provision.o

Modified: team/russell/chan_refcount/channels/busy.h
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/channels/busy.h?view=diff&rev=89502&r1=89501&r2=89502
==============================================================================
--- team/russell/chan_refcount/channels/busy.h (original)
+++ team/russell/chan_refcount/channels/busy.h Wed Nov 21 13:55:15 2007
@@ -1,21 +1,3 @@
-/*
- * Asterisk -- An open source telephony toolkit.
- *
- * Copyright (C) 1999 - 2007, Digium, Inc.
- *
- * Mark Spencer <markster at digium.com>
- *
- * See http://www.asterisk.org for more information about
- * the Asterisk project. Please do not directly contact
- * any of the maintainers of this project for assistance;
- * the project provides a web site, mailing lists and IRC
- * channels for your use.
- *
- * This program is free software, distributed under the terms of
- * the GNU General Public License Version 2. See the LICENSE file
- * at the top of the source tree.
- */
-
 /* busy.h: Generated from frequencies 480 and 620 
    by gentone.  400 samples  */
 static short busy[400] = {

Modified: team/russell/chan_refcount/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/channels/chan_agent.c?view=diff&rev=89502&r1=89501&r2=89502
==============================================================================
--- team/russell/chan_refcount/channels/chan_agent.c (original)
+++ team/russell/chan_refcount/channels/chan_agent.c Wed Nov 21 13:55:15 2007
@@ -83,7 +83,7 @@
 static const char synopsis3[] = "Record agent's outgoing call";
 
 static const char descrip[] =
-"  AgentLogin([AgentNo][|options]):\n"
+"  AgentLogin([AgentNo][,options]):\n"
 "Asks the agent to login to the system.  Always returns -1.  While\n"
 "logged in, the agent can receive calls and will hear a 'beep'\n"
 "when a new call comes in. The agent can dump the call by pressing\n"

Modified: team/russell/chan_refcount/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/channels/chan_sip.c?view=diff&rev=89502&r1=89501&r2=89502
==============================================================================
--- team/russell/chan_refcount/channels/chan_sip.c (original)
+++ team/russell/chan_refcount/channels/chan_sip.c Wed Nov 21 13:55:15 2007
@@ -7755,38 +7755,43 @@
 	add_header(&req, "Supported", SUPPORTED_EXTENSIONS);
 	if (p->options && p->options->addsipheaders && p->owner) {
 		struct ast_channel *ast = ast_channel_ref(p->owner); /* The owner channel */
-		struct varshead *headp = &ast->varshead;
-
-			if (!headp)
-				ast_log(LOG_WARNING,"No Headp for the channel...ooops!\n");
-			else {
-				const struct ast_var_t *current;
-				AST_LIST_TRAVERSE(headp, current, entries) {  
-					/* SIPADDHEADER: Add SIP header to outgoing call */
-					if (!strncasecmp(ast_var_name(current), "SIPADDHEADER", strlen("SIPADDHEADER"))) {
-						char *content, *end;
-						const char *header = ast_var_value(current);
-						char *headdup = ast_strdupa(header);
-
-						/* Strip of the starting " (if it's there) */
-						if (*headdup == '"')
-					 		headdup++;
-						if ((content = strchr(headdup, ':'))) {
-							*content++ = '\0';
-							content = ast_skip_blanks(content); /* Skip white space */
-							/* Strip the ending " (if it's there) */
-					 		end = content + strlen(content) -1;	
-							if (*end == '"')
-								*end = '\0';
-						
-							add_header(&req, headdup, content);
-							if (sipdebug)
-								ast_debug(1, "Adding SIP Header \"%s\" with content :%s: \n", headdup, content);
-						}
+		struct varshead *headp;
+	
+		ast_channel_lock(chan);
+
+		headp = &chan->varshead;
+
+		if (!headp)
+			ast_log(LOG_WARNING,"No Headp for the channel...ooops!\n");
+		else {
+			const struct ast_var_t *current;
+			AST_LIST_TRAVERSE(headp, current, entries) {  
+				/* SIPADDHEADER: Add SIP header to outgoing call */
+				if (!strncasecmp(ast_var_name(current), "SIPADDHEADER", strlen("SIPADDHEADER"))) {
+					char *content, *end;
+					const char *header = ast_var_value(current);
+					char *headdup = ast_strdupa(header);
+
+					/* Strip of the starting " (if it's there) */
+					if (*headdup == '"')
+				 		headdup++;
+					if ((content = strchr(headdup, ':'))) {
+						*content++ = '\0';
+						content = ast_skip_blanks(content); /* Skip white space */
+						/* Strip the ending " (if it's there) */
+				 		end = content + strlen(content) -1;	
+						if (*end == '"')
+							*end = '\0';
+					
+						add_header(&req, headdup, content);
+						if (sipdebug)
+							ast_debug(1, "Adding SIP Header \"%s\" with content :%s: \n", headdup, content);
 					}
 				}
 			}
-
+		}
+
+		ast_channel_unlock(chan);
 		ast_channel_unref(ast);
 	}
 	if (sdp) {

Modified: team/russell/chan_refcount/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/channels/chan_zap.c?view=diff&rev=89502&r1=89501&r2=89502
==============================================================================
--- team/russell/chan_refcount/channels/chan_zap.c (original)
+++ team/russell/chan_refcount/channels/chan_zap.c Wed Nov 21 13:55:15 2007
@@ -1073,7 +1073,13 @@
 		}
 	}
 	bs = READ_SIZE;
-	if (ioctl(fd, ZT_SET_BLOCKSIZE, &bs) == -1) return -1;
+	if (ioctl(fd, ZT_SET_BLOCKSIZE, &bs) == -1) {
+		ast_log(LOG_WARNING, "Unable to set blocksize '%d': %s\n", bs,  strerror(errno));
+		x = errno;
+		close(fd);
+		errno = x;
+		return -1;
+	}
 	return fd;
 }
 
@@ -13206,8 +13212,10 @@
 			continue;
 		}
 		  /* if got exception */
-		if (fds[0].revents & POLLPRI)
+		if (fds[0].revents & POLLPRI) {
+			ast_free(mybuf);
 			return -1;
+		}
 		if (!(fds[0].revents & POLLOUT)) {
 			ast_debug(1, "write fd not ready on channel %d\n", p->channel);
 			continue;

Modified: team/russell/chan_refcount/channels/ringtone.h
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/channels/ringtone.h?view=diff&rev=89502&r1=89501&r2=89502
==============================================================================
--- team/russell/chan_refcount/channels/ringtone.h (original)
+++ team/russell/chan_refcount/channels/ringtone.h Wed Nov 21 13:55:15 2007
@@ -1,21 +1,3 @@
-/*
- * Asterisk -- An open source telephony toolkit.
- *
- * Copyright (C) 1999 - 2007, Digium, Inc.
- *
- * Mark Spencer <markster at digium.com>
- *
- * See http://www.asterisk.org for more information about
- * the Asterisk project. Please do not directly contact
- * any of the maintainers of this project for assistance;
- * the project provides a web site, mailing lists and IRC
- * channels for your use.
- *
- * This program is free software, distributed under the terms of
- * the GNU General Public License Version 2. See the LICENSE file
- * at the top of the source tree.
- */
-
 /* ringtone.h: Generated from frequencies 440 and 480 
    by gentone.  200 samples  */
 static short ringtone[200] = {

Modified: team/russell/chan_refcount/configs/zapata.conf.sample
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/configs/zapata.conf.sample?view=diff&rev=89502&r1=89501&r2=89502
==============================================================================
--- team/russell/chan_refcount/configs/zapata.conf.sample (original)
+++ team/russell/chan_refcount/configs/zapata.conf.sample Wed Nov 21 13:55:15 2007
@@ -154,7 +154,7 @@
 ; T305: Wait for DISCONNECT acknowledge (default 30000 ms)
 ; T308: Wait for RELEASE acknowledge (default 4000 ms)
 ; T309: Maintain active calls on Layer 2 disconnection (default -1, 
-        Asterisk clears calls)
+;       Asterisk clears calls)
 ;       EuroISDN: 6000 to 12000 ms, according to (N200 + 1) x T200 + 2s
 ;       May vary in other ISDN standards (Q.931 1993 : 90000 ms)
 ; T313: Wait for CONNECT acknowledge, CPE side only (default 3000 ms)

Modified: team/russell/chan_refcount/configure
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/configure?view=diff&rev=89502&r1=89501&r2=89502
==============================================================================
--- team/russell/chan_refcount/configure (original)
+++ team/russell/chan_refcount/configure Wed Nov 21 13:55:15 2007
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.ac Revision: 88184 .
+# From configure.ac Revision: 88250 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.61.
 #
@@ -15046,6 +15046,59 @@
 done
 
 
+# check if we have IP_PKTINFO constant defined
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <netinet/in.h>
+int
+main ()
+{
+int pi = IP_PKTINFO;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_PKTINFO 1
+_ACEOF
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	{ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+
 # some systems already have gethostbyname_r so we don't need to build ours in main/utils.c
 { echo "$as_me:$LINENO: checking for library containing gethostbyname_r" >&5
 echo $ECHO_N "checking for library containing gethostbyname_r... $ECHO_C" >&6; }

Modified: team/russell/chan_refcount/configure.ac
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/configure.ac?view=diff&rev=89502&r1=89501&r2=89502
==============================================================================
--- team/russell/chan_refcount/configure.ac (original)
+++ team/russell/chan_refcount/configure.ac Wed Nov 21 13:55:15 2007
@@ -283,6 +283,15 @@
 # https support (in main/http.c) uses funopen on BSD systems,
 # fopencookie on linux
 AC_CHECK_FUNCS([funopen fopencookie])
+
+# check if we have IP_PKTINFO constant defined
+AC_LINK_IFELSE(
+		AC_LANG_PROGRAM([#include <netinet/in.h>],
+						[int pi = IP_PKTINFO;]),
+		AC_MSG_RESULT(yes)
+		AC_DEFINE([HAVE_PKTINFO], 1, [Define to 1 if your system defines IP_PKTINFO.]),
+		AC_MSG_RESULT(no)
+)
 
 # some systems already have gethostbyname_r so we don't need to build ours in main/utils.c
 AC_SEARCH_LIBS(gethostbyname_r, [socket nsl])

Modified: team/russell/chan_refcount/include/asterisk/autoconfig.h.in
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/include/asterisk/autoconfig.h.in?view=diff&rev=89502&r1=89501&r2=89502
==============================================================================
--- team/russell/chan_refcount/include/asterisk/autoconfig.h.in (original)
+++ team/russell/chan_refcount/include/asterisk/autoconfig.h.in Wed Nov 21 13:55:15 2007
@@ -519,6 +519,9 @@
 
 /* Define to indicate the PostgreSQL library */
 #undef HAVE_PGSQL
+
+/* Define to 1 if your system defines IP_PKTINFO. */
+#undef HAVE_PKTINFO
 
 /* Define this to indicate the ${POPT_DESCRIP} library */
 #undef HAVE_POPT

Modified: team/russell/chan_refcount/include/asterisk/lock.h
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/include/asterisk/lock.h?view=diff&rev=89502&r1=89501&r2=89502
==============================================================================
--- team/russell/chan_refcount/include/asterisk/lock.h (original)
+++ team/russell/chan_refcount/include/asterisk/lock.h Wed Nov 21 13:55:15 2007
@@ -675,11 +675,6 @@
 	int res;
 	pthread_mutexattr_t attr;
 
-#ifdef BSD
-	/* Check for already init'ed mutex for BSD */
-	if (*pmutex != ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER))
-		return 0;
-#endif /* BSD */
 	pthread_mutexattr_init(&attr);
 	pthread_mutexattr_settype(&attr, AST_MUTEX_KIND);
 
@@ -692,42 +687,21 @@
 
 static inline int ast_mutex_unlock(ast_mutex_t *pmutex)
 {
-#ifdef BSD
-	/* Check for uninitialized mutex for BSD */
-	if (*pmutex == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
-		ast_mutex_init(pmutex);
-		return 0;
-	}
-#endif /* BSD */
 	return pthread_mutex_unlock(pmutex);
 }
 
 static inline int ast_mutex_destroy(ast_mutex_t *pmutex)
 {
-#ifdef BSD
-	if (*pmutex == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER))
-		return 0;
-#endif /* BSD */
 	return pthread_mutex_destroy(pmutex);
 }
 
 static inline int ast_mutex_lock(ast_mutex_t *pmutex)
 {
-#ifdef BSD
-	/* Check for uninitialized mutex for BSD */
-	if (*pmutex == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER))
-		ast_mutex_init(pmutex);
-#endif /* BSD */
 	__MTX_PROF(pmutex);
 }
 
 static inline int ast_mutex_trylock(ast_mutex_t *pmutex)
 {
-#ifdef BSD
-	/* Check for uninitialized mutex for BSD */
-	if (*pmutex == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER))
-		ast_mutex_init(pmutex);
-#endif /* BSD */
 	return pthread_mutex_trylock(pmutex);
 }
 
@@ -1037,11 +1011,6 @@
 	int res;
 	pthread_rwlockattr_t attr;
 
-#ifdef BSD
-	/* Check for already init'ed lock for BSD */
-	if (*prwlock != ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE))
-		return 0;
-#endif /* BSD */
 	pthread_rwlockattr_init(&attr);
 
 #ifdef HAVE_PTHREAD_RWLOCK_PREFER_WRITER_NP
@@ -1055,67 +1024,31 @@
 
 static inline int ast_rwlock_destroy(ast_rwlock_t *prwlock)
 {
-#ifdef BSD
-	/* Check for uninitialized mutex for BSD */
-	if (*prwlock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE))
-		return 0;
-#endif /* BSD */
 	return pthread_rwlock_destroy(prwlock);
 }
 
 static inline int ast_rwlock_unlock(ast_rwlock_t *prwlock)
 {
-#ifdef BSD
-	/* Check for uninitialized lock for BSD */
-	if (*prwlock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
-		ast_rwlock_init(prwlock);
-		return 0;
-	}
-#endif /* BSD */
 	return pthread_rwlock_unlock(prwlock);
 }
 
 static inline int ast_rwlock_rdlock(ast_rwlock_t *prwlock)
 {
-#ifdef BSD
-	/* Check for uninitialized lock for BSD */
-	if (*prwlock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
-		ast_rwlock_init(prwlock);
-	}
-#endif /* BSD */
 	return pthread_rwlock_rdlock(prwlock);
 }
 
 static inline int ast_rwlock_tryrdlock(ast_rwlock_t *prwlock)
 {
-#ifdef BSD
-	/* Check for uninitialized lock for BSD */
-	if (*prwlock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
-		ast_rwlock_init(prwlock);
-	}
-#endif /* BSD */
 	return pthread_rwlock_tryrdlock(prwlock);
 }
 
 static inline int ast_rwlock_wrlock(ast_rwlock_t *prwlock)
 {
-#ifdef BSD
-	/* Check for uninitialized lock for BSD */
-	if (*prwlock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
-		ast_rwlock_init(prwlock);
-	}
-#endif /* BSD */
 	return pthread_rwlock_wrlock(prwlock);
 }
 
 static inline int ast_rwlock_trywrlock(ast_rwlock_t *prwlock)
 {
-#ifdef BSD 
-	/* Check for uninitialized lock for BSD */
-	if (*prwlock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
-		ast_rwlock_init(prwlock);
-	}
-#endif /* BSD */
 	return pthread_rwlock_trywrlock(prwlock);
 }
 #endif /* !DEBUG_THREADS */

Modified: team/russell/chan_refcount/include/asterisk/pbx.h
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/include/asterisk/pbx.h?view=diff&rev=89502&r1=89501&r2=89502
==============================================================================
--- team/russell/chan_refcount/include/asterisk/pbx.h (original)
+++ team/russell/chan_refcount/include/asterisk/pbx.h Wed Nov 21 13:55:15 2007
@@ -856,8 +856,19 @@
 	struct ast_ignorepat *ip);
 struct ast_sw *ast_walk_context_switches(struct ast_context *con, struct ast_sw *sw);
 
+/*!
+ * \note Will lock the channel.
+ */
 int pbx_builtin_serialize_variables(struct ast_channel *chan, struct ast_str **buf);
+
+/*!
+ * \note Will lock the channel.
+ */
 const char *pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name);
+
+/*!
+ * \note Will lock the channel.
+ */
 void pbx_builtin_pushvar_helper(struct ast_channel *chan, const char *name, const char *value);
 
 /*!
@@ -865,7 +876,7 @@
  *
  * \param chan if non-NULL, set a channel variable, otherwise set a global variable
  *
- * \note If the chan argument is not NULL, it must be locked before calling this function.
+ * \note Will lock the channel.
  *
  * \return Nothing
  */
@@ -877,15 +888,21 @@
  * \param chan if non-NULL, retrieve a channel variable, otherwise retrieve 
  *             a global variable
  *
- * \note If the chan argument is not NULL, it must be locked before calling this function.
+ * \note Will lock the channel.
  *
  * \return Nothing
  */
 void pbx_retrieve_variable(struct ast_channel *c, const char *var, char **ret, char *workspace, int workspacelen, struct varshead *headp);
 
 void pbx_builtin_clear_globals(void);
+
+/*!
+ * \note Will lock the channel.
+ */
 int pbx_builtin_setvar(struct ast_channel *chan, void *data);
+
 int pbx_builtin_raise_exception(struct ast_channel *chan, void *data);
+
 void pbx_substitute_variables_helper(struct ast_channel *c,const char *cp1,char *cp2,int count);
 void pbx_substitute_variables_varshead(struct varshead *headp, const char *cp1, char *cp2, int count);
 

Modified: team/russell/chan_refcount/include/asterisk/srv.h
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/include/asterisk/srv.h?view=diff&rev=89502&r1=89501&r2=89502
==============================================================================
--- team/russell/chan_refcount/include/asterisk/srv.h (original)
+++ team/russell/chan_refcount/include/asterisk/srv.h Wed Nov 21 13:55:15 2007
@@ -26,10 +26,9 @@
 /*!
   \file srv.h
   \brief Support for DNS SRV records, used in to locate SIP services.
-  \note Note: This SRV record support is very minimal; it will only
-        return the first (lowest priority) answer that is received, and
-	has no provisions for the 'weight' elements of the records or
-	retrying if the first returned result fails.
+  \note Note: This SRV record support will respect the priority and
+        weight elements of the records that are returned, but there are
+	no provisions for retrying or failover between records.
 */
 
 /*! Lookup entry in SRV records Returns 1 if found, 0 if not found, -1 on hangup 

Modified: team/russell/chan_refcount/main/Makefile
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/main/Makefile?view=diff&rev=89502&r1=89501&r2=89502
==============================================================================
--- team/russell/chan_refcount/main/Makefile (original)
+++ team/russell/chan_refcount/main/Makefile Wed Nov 21 13:55:15 2007
@@ -85,6 +85,9 @@
 endif
 
 ifeq ($(OSARCH),FreeBSD)
+  # -V is understood by BSD Make, not by GNU make.
+  BSDVERSION=$(shell make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk)
+  AST_LIBS+=$(shell if test $(BSDVERSION) -lt 502102 ; then echo "-lc_r"; else echo "-pthread"; fi)
   AST_LIBS+=-lcrypto
 endif
 

Modified: team/russell/chan_refcount/main/channel.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/main/channel.c?view=diff&rev=89502&r1=89501&r2=89502
==============================================================================
--- team/russell/chan_refcount/main/channel.c (original)
+++ team/russell/chan_refcount/main/channel.c Wed Nov 21 13:55:15 2007
@@ -2091,14 +2091,20 @@
 static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
 {
 	struct ast_frame *f = NULL;	/* the return value */
-	struct ast_channel *base = NULL;
 	int blah;
 	int prestate;
+	int count = 0;
 
 	/* this function is very long so make sure there is only one return
-	 * point at the end (there is only one exception to this).
+	 * point at the end (there are only two exceptions to this).
 	 */
-	ast_channel_lock(chan);
+	while(ast_channel_trylock(chan)) {
+		if(count++ > 10) 
+			/*cannot goto done since the channel is not locked*/
+			return &ast_null_frame;
+		usleep(1);
+	}
+
 	if (chan->masq) {
 		if (ast_do_masquerade(chan))
 			ast_log(LOG_WARNING, "Failed to perform masquerade\n");
@@ -2114,23 +2120,6 @@
 		goto done;
 	}
 	prestate = chan->_state;
-
-	/* Check if there's an underlying channel */
-	if (chan->tech->get_base_channel && (base = chan->tech->get_base_channel(chan)) != chan) {
-		int count = 0;
-		while (!base || ast_channel_trylock(base)) {
-			if (count++ > 10) {
-				f = &ast_null_frame;
-				goto done;
-			}
-			ast_channel_unlock(chan);
-			usleep(1);
-			ast_channel_lock(chan);
-			base = chan->tech->get_base_channel(chan);
-		}
-		ast_channel_unlock(chan);
-		chan = base;
-	}
 
 	if (!ast_test_flag(chan, AST_FLAG_DEFER_DTMF | AST_FLAG_EMULATE_DTMF | AST_FLAG_IN_DTMF) && 
 	    !ast_strlen_zero(chan->dtmfq) && 

Modified: team/russell/chan_refcount/main/pbx.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/main/pbx.c?view=diff&rev=89502&r1=89501&r2=89502
==============================================================================
--- team/russell/chan_refcount/main/pbx.c (original)
+++ team/russell/chan_refcount/main/pbx.c Wed Nov 21 13:55:15 2007
@@ -1187,6 +1187,7 @@
 	struct varshead *places[2] = { headp, &globals };	/* list of places where we may look */
 
 	if (c) {
+		ast_channel_lock(c);
 		places[0] = &c->varshead;
 	}
 	/*
@@ -1284,6 +1285,9 @@
 		if (need_substring)
 			*ret = substring(*ret, offset, length, workspace, workspacelen);
 	}
+
+	if (c)
+		ast_channel_unlock(c);
 }
 
 static void exception_store_free(void *data)
@@ -5920,6 +5924,8 @@
 	(*buf)->used = 0;
 	(*buf)->str[0] = '\0';
 
+	ast_channel_lock(chan);
+
 	AST_LIST_TRAVERSE(&chan->varshead, variables, entries) {
 		if ((var = ast_var_name(variables)) && (val = ast_var_value(variables))
 		   /* && !ast_strlen_zero(var) && !ast_strlen_zero(val) */
@@ -5933,6 +5939,8 @@
 			break;
 	}
 
+	ast_channel_unlock(chan);
+
 	return total;
 }
 
@@ -5945,8 +5953,11 @@
 
 	if (!name)
 		return NULL;
-	if (chan)
+
+	if (chan) {
+		ast_channel_lock(chan);
 		places[0] = &chan->varshead;
+	}
 
 	for (i = 0; i < 2; i++) {
 		if (!places[i])
@@ -5965,6 +5976,9 @@
 			break;
 	}
 
+	if (chan)
+		ast_channel_unlock(chan);
+
 	return ret;
 }
 
@@ -5981,18 +5995,25 @@
 		return;
 	}
 
-	headp = (chan) ? &chan->varshead : &globals;
+	if (chan) {
+		ast_channel_lock(chan);
+		headp = &chan->varshead;
+	} else {
+		ast_rwlock_wrlock(&globalslock);
+		headp = &globals;
+	}
 
 	if (value) {
 		if (headp == &globals)
 			ast_verb(2, "Setting global variable '%s' to '%s'\n", name, value);
 		newvariable = ast_var_assign(name, value);
-		if (headp == &globals)
-			ast_rwlock_wrlock(&globalslock);
 		AST_LIST_INSERT_HEAD(headp, newvariable, entries);
-		if (headp == &globals)
-			ast_rwlock_unlock(&globalslock);
-	}
+	}
+
+	if (chan)
+		ast_channel_unlock(chan);
+	else
+		ast_rwlock_unlock(&globalslock);
 }
 
 void pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
@@ -6001,7 +6022,6 @@
 	struct varshead *headp;
 	const char *nametail = name;
 
-	/* XXX may need locking on the channel ? */
 	if (name[strlen(name) - 1] == ')') {
 		char *function = ast_strdupa(name);
 
@@ -6009,7 +6029,13 @@
 		return;
 	}
 
-	headp = (chan) ? &chan->varshead : &globals;
+	if (chan) {
+		ast_channel_lock(chan);
+		headp = &chan->varshead;
+	} else {
+		ast_rwlock_wrlock(&globalslock);
+		headp = &globals;
+	}
 
 	/* For comparison purposes, we have to strip leading underscores */
 	if (*nametail == '_') {
@@ -6018,8 +6044,6 @@
 			nametail++;
 	}
 
-	if (headp == &globals)
-		ast_rwlock_wrlock(&globalslock);
 	AST_LIST_TRAVERSE (headp, newvariable, entries) {
 		if (strcasecmp(ast_var_name(newvariable), nametail) == 0) {
 			/* there is already such a variable, delete it */
@@ -6043,7 +6067,9 @@
 			chan ? chan->uniqueid : "none");
 	}
 
-	if (headp == &globals)
+	if (chan)
+		ast_channel_unlock(chan);
+	else
 		ast_rwlock_unlock(&globalslock);
 }
 

Modified: team/russell/chan_refcount/utils/Makefile
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/utils/Makefile?view=diff&rev=89502&r1=89501&r2=89502
==============================================================================
--- team/russell/chan_refcount/utils/Makefile (original)
+++ team/russell/chan_refcount/utils/Makefile Wed Nov 21 13:55:15 2007
@@ -28,6 +28,10 @@
 
 ifeq ($(OSARCH),OpenBSD)
   UTILS:=$(filter-out muted,$(UTILS))
+endif
+
+ifneq ($(findstring darwin,$(OSARCH)),)
+  AUDIO_LIBS=-framework CoreAudio
 endif
 
 ifeq ($(POPT_LIB),)




More information about the asterisk-commits mailing list