[asterisk-commits] russell: branch russell/events r84325 - in /team/russell/events: ./ channels/...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Oct 1 17:25:58 CDT 2007


Author: russell
Date: Mon Oct  1 17:25:58 2007
New Revision: 84325

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

Modified:
    team/russell/events/   (props changed)
    team/russell/events/Makefile
    team/russell/events/Makefile.rules
    team/russell/events/channels/Makefile
    team/russell/events/channels/chan_agent.c
    team/russell/events/include/asterisk/lock.h
    team/russell/events/main/channel.c
    team/russell/events/main/manager.c
    team/russell/events/main/utils.c

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

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

Propchange: team/russell/events/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Oct  1 17:25:58 2007
@@ -1,1 +1,1 @@
-/trunk:1-84237
+/trunk:1-84324

Modified: team/russell/events/Makefile
URL: http://svn.digium.com/view/asterisk/team/russell/events/Makefile?view=diff&rev=84325&r1=84324&r2=84325
==============================================================================
--- team/russell/events/Makefile (original)
+++ team/russell/events/Makefile Mon Oct  1 17:25:58 2007
@@ -260,6 +260,7 @@
 SUBDIRS:=$(OTHER_SUBDIRS) $(MOD_SUBDIRS)
 SUBDIRS_INSTALL:=$(SUBDIRS:%=%-install)
 SUBDIRS_CLEAN:=$(SUBDIRS:%=%-clean)
+SUBDIRS_DIST_CLEAN:=$(SUBDIRS:%=%-dist-clean)
 SUBDIRS_UNINSTALL:=$(SUBDIRS:%=%-uninstall)
 MOD_SUBDIRS_EMBED_LDSCRIPT:=$(MOD_SUBDIRS:%=%-embed-ldscript)
 MOD_SUBDIRS_EMBED_LDFLAGS:=$(MOD_SUBDIRS:%=%-embed-ldflags)
@@ -373,6 +374,9 @@
 $(SUBDIRS_CLEAN):
 	@$(MAKE) --no-print-directory -C $(@:-clean=) clean
 
+$(SUBDIRS_DIST_CLEAN):
+	@$(MAKE) --no-print-directory -C $(@:-dist-clean=) dist-clean
+
 clean: $(SUBDIRS_CLEAN)
 	rm -f defaults.h
 	rm -f include/asterisk/build.h
@@ -382,7 +386,7 @@
 
 dist-clean: distclean
 
-distclean: clean
+distclean: $(SUBDIRS_DIST_CLEAN) clean
 	@$(MAKE) -C menuselect dist-clean
 	@$(MAKE) -C sounds dist-clean
 	rm -f menuselect.makeopts makeopts menuselect-tree menuselect.makedeps
@@ -731,4 +735,4 @@
 asterisk.pdf:
 	$(MAKE) -C doc/tex asterisk.pdf
 
-.PHONY: menuselect main sounds clean dist-clean distclean all prereqs cleantest uninstall _uninstall uninstall-all dont-optimize $(SUBDIRS_INSTALL) $(SUBDIRS_CLEAN) $(SUBDIRS_UNINSTALL) $(SUBDIRS) $(MOD_SUBDIRS_EMBED_LDSCRIPT) $(MOD_SUBDIRS_EMBED_LDFLAGS) $(MOD_SUBDIRS_EMBED_LIBS) menuselect.makeopts
+.PHONY: menuselect main sounds clean dist-clean distclean all prereqs cleantest uninstall _uninstall uninstall-all dont-optimize $(SUBDIRS_INSTALL) $(SUBDIRS_DIST_CLEAN) $(SUBDIRS_CLEAN) $(SUBDIRS_UNINSTALL) $(SUBDIRS) $(MOD_SUBDIRS_EMBED_LDSCRIPT) $(MOD_SUBDIRS_EMBED_LDFLAGS) $(MOD_SUBDIRS_EMBED_LIBS) menuselect.makeopts

Modified: team/russell/events/Makefile.rules
URL: http://svn.digium.com/view/asterisk/team/russell/events/Makefile.rules?view=diff&rev=84325&r1=84324&r2=84325
==============================================================================
--- team/russell/events/Makefile.rules (original)
+++ team/russell/events/Makefile.rules Mon Oct  1 17:25:58 2007
@@ -16,6 +16,8 @@
 # behaviour. ECHO_PREFIX prefixes the comment, CMD_PREFIX prefixes the command.
 
 -include $(ASTTOPDIR)/makeopts
+
+.PHONY: dist-clean
 
 ifeq ($(NOISY_BUILD),)
    ECHO_PREFIX=@
@@ -107,3 +109,5 @@
 %: %.o
 	$(ECHO_PREFIX) echo "   [LD] $^ -> $@"
 	$(CMD_PREFIX) $(CXX) $(STATIC_BUILD) -o $@ $(PTHREAD_CFLAGS) $(ASTLDFLAGS) $^ $(PTHREAD_LIBS) $(LIBS)
+
+dist-clean::

Modified: team/russell/events/channels/Makefile
URL: http://svn.digium.com/view/asterisk/team/russell/events/channels/Makefile?view=diff&rev=84325&r1=84324&r2=84325
==============================================================================
--- team/russell/events/channels/Makefile (original)
+++ team/russell/events/channels/Makefile Mon Oct  1 17:25:58 2007
@@ -68,7 +68,6 @@
 H323LDFLAGS+=-Wl,--version-script=h323/noexport.map
 clean::
 	$(MAKE) -C h323 clean
-	rm -f h323/Makefile
 else
 h323/libchanh323.a h323/Makefile.ast:
 	$(CMD_PREFIX) $(MAKE) -C h323
@@ -80,6 +79,9 @@
 	$(CMD_PREFIX) echo "***************************************************************"
 	$(CMD_PREFIX) exit 1
 endif
+
+dist-clean::
+	rm -f h323/Makefile
 
 gentone: gentone.c
 	$(ECHO_PREFIX) echo "   [LD] $^ -> $@"

Modified: team/russell/events/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/channels/chan_agent.c?view=diff&rev=84325&r1=84324&r2=84325
==============================================================================
--- team/russell/events/channels/chan_agent.c (original)
+++ team/russell/events/channels/chan_agent.c Mon Oct  1 17:25:58 2007
@@ -789,17 +789,20 @@
 	}
 }
 
+/*! \brief return the channel or base channel if one exists.  This function assumes the channel it is called on is already locked */
 struct ast_channel* agent_get_base_channel(struct ast_channel *chan)
 {
 	struct agent_pvt *p = NULL;
-	struct ast_channel *base = NULL;
-	
+	struct ast_channel *base = chan;
+
+	/* chan is locked by the calling function */
 	if (!chan || !chan->tech_pvt) {
 		ast_log(LOG_ERROR, "whoa, you need a channel (0x%ld) with a tech_pvt (0x%ld) to get a base channel.\n", (long)chan, (chan)?(long)chan->tech_pvt:(long)NULL);
-	} else {
-		p = chan->tech_pvt;
+		return NULL;
+	}
+	p = chan->tech_pvt;
+	if (p->chan) 
 		base = p->chan;
-	}
 	return base;
 }
 

Modified: team/russell/events/include/asterisk/lock.h
URL: http://svn.digium.com/view/asterisk/team/russell/events/include/asterisk/lock.h?view=diff&rev=84325&r1=84324&r2=84325
==============================================================================
--- team/russell/events/include/asterisk/lock.h (original)
+++ team/russell/events/include/asterisk/lock.h Mon Oct  1 17:25:58 2007
@@ -126,6 +126,12 @@
 
 static pthread_mutex_t empty_mutex;
 
+enum ast_lock_type {
+	AST_MUTEX,
+	AST_RDLOCK,
+	AST_WRLOCK,
+};
+
 /*!
  * \brief Store lock info for the current thread
  *
@@ -134,8 +140,8 @@
  * lock info struct.  The lock is marked as pending as the thread is waiting
  * on the lock.  ast_mark_lock_acquired() will mark it as held by this thread.
  */
-void ast_store_lock_info(const char *filename, int line_num, 
-	const char *func, const char *lock_name, void *lock_addr);
+void ast_store_lock_info(enum ast_lock_type type, const char *filename,
+	int line_num, const char *func, const char *lock_name, void *lock_addr);
 
 /*!
  * \brief Mark the last lock as acquired
@@ -249,7 +255,7 @@
 	int canlog = strcmp(filename, "logger.c");
 
 	if (t->track)
-		ast_store_lock_info(filename, lineno, func, mutex_name, &t->mutex);
+		ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, &t->mutex);
 
 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS)
 	if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
@@ -333,7 +339,7 @@
 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
 
 	if (t->track)
-		ast_store_lock_info(filename, lineno, func, mutex_name, &t->mutex);
+		ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, &t->mutex);
 
 	if (!(res = pthread_mutex_trylock(&t->mutex))) {
 		if (t->track)
@@ -469,7 +475,7 @@
 		DO_THREAD_CRASH;
 	} else {
 		if (t->track)
-			ast_store_lock_info(filename, lineno, func, mutex_name, &t->mutex);
+			ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, &t->mutex);
 
 		if (t->reentrancy < AST_MAX_REENTRANCY) {
 			t->file[t->reentrancy] = filename;
@@ -530,7 +536,7 @@
 		DO_THREAD_CRASH;
 	} else {
 		if (t->track)
-			ast_store_lock_info(filename, lineno, func, mutex_name, &t->mutex);
+			ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, &t->mutex);
 
 		if (t->reentrancy < AST_MAX_REENTRANCY) {
 			t->file[t->reentrancy] = filename;
@@ -722,7 +728,7 @@
 	const char *file, int line, const char *func)
 {
 	int res;
-	ast_store_lock_info(file, line, func, name, lock);
+	ast_store_lock_info(AST_RDLOCK, file, line, func, name, lock);
 	res = pthread_rwlock_rdlock(lock);
 	if (!res)
 		ast_mark_lock_acquired();
@@ -738,7 +744,7 @@
 	const char *file, int line, const char *func)
 {
 	int res;
-	ast_store_lock_info(file, line, func, name, lock);
+	ast_store_lock_info(AST_WRLOCK, file, line, func, name, lock);
 	res = pthread_rwlock_wrlock(lock);
 	if (!res)
 		ast_mark_lock_acquired();
@@ -754,7 +760,7 @@
 	const char *file, int line, const char *func)
 {
 	int res;
-	ast_store_lock_info(file, line, func, name, lock);
+	ast_store_lock_info(AST_RDLOCK, file, line, func, name, lock);
 	res = pthread_rwlock_tryrdlock(lock);
 	if (!res)
 		ast_mark_lock_acquired();
@@ -770,7 +776,7 @@
 	const char *file, int line, const char *func)
 {
 	int res;
-	ast_store_lock_info(file, line, func, name, lock);
+	ast_store_lock_info(AST_WRLOCK, file, line, func, name, lock);
 	res = pthread_rwlock_trywrlock(lock);
 	if (!res)
 		ast_mark_lock_acquired();
@@ -780,6 +786,7 @@
 }
 
 #else
+
 static inline int ast_rwlock_unlock(ast_rwlock_t *prwlock)
 {
 	return pthread_rwlock_unlock(prwlock);

Modified: team/russell/events/main/channel.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/main/channel.c?view=diff&rev=84325&r1=84324&r2=84325
==============================================================================
--- team/russell/events/main/channel.c (original)
+++ team/russell/events/main/channel.c Mon Oct  1 17:25:58 2007
@@ -3333,7 +3333,7 @@
 int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clone)
 {
 	int res = -1;
-	struct ast_channel *final_orig, *final_clone;
+	struct ast_channel *final_orig, *final_clone, *base;
 
 retrymasq:
 	final_orig = original;
@@ -3353,6 +3353,10 @@
 
 	if (clone->_bridge && (clone->_bridge != ast_bridged_channel(clone)) && (clone->_bridge->_bridge != clone))
 		final_clone = clone->_bridge;
+	
+	if (final_clone->tech->get_base_channel && (base = final_clone->tech->get_base_channel(final_clone))) {
+		final_clone = base;
+	}
 
 	if ((final_orig != original) || (final_clone != clone)) {
 		/* Lots and lots of deadlock avoidance.  The main one we're competing with

Modified: team/russell/events/main/manager.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/main/manager.c?view=diff&rev=84325&r1=84324&r2=84325
==============================================================================
--- team/russell/events/main/manager.c (original)
+++ team/russell/events/main/manager.c Mon Oct  1 17:25:58 2007
@@ -1787,7 +1787,7 @@
 	const char *exten = astman_get_header(m, "Exten");
 	const char *context = astman_get_header(m, "Context");
 	const char *priority = astman_get_header(m, "Priority");
-	struct ast_channel *base, *chan, *chan2 = NULL;
+	struct ast_channel *chan, *chan2 = NULL;
 	int pi = 0;
 	int res;
 
@@ -1809,14 +1809,6 @@
 		astman_send_error(s, m, buf);
 		return 0;
 	}
-	if (chan->tech->get_base_channel) {
-		base = chan->tech->get_base_channel(chan);
-		if (base) {
-			ast_mutex_unlock(&chan->lock);
-			chan = base;
-			ast_mutex_lock(&chan->lock);
-		}
-	}
 	if (ast_check_hangup(chan)) {
 		astman_send_error(s, m, "Redirect failed, channel not up.\n");
 		ast_channel_unlock(chan);
@@ -1829,14 +1821,6 @@
 		ast_channel_unlock(chan);
 		ast_channel_unlock(chan2);
 		return 0;
-	}
-	if (chan2 && chan2->tech->get_base_channel) {
-		base = chan2->tech->get_base_channel(chan2);
-		if (base) {
-			ast_mutex_unlock(&chan2->lock);
-			chan2 = base;
-			ast_mutex_lock(&chan2->lock);
-		}
 	}
 	res = ast_async_goto(chan, context, exten, pi);
 	if (!res) {

Modified: team/russell/events/main/utils.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/main/utils.c?view=diff&rev=84325&r1=84324&r2=84325
==============================================================================
--- team/russell/events/main/utils.c (original)
+++ team/russell/events/main/utils.c Mon Oct  1 17:25:58 2007
@@ -547,6 +547,7 @@
 		const char *lock_name;
 		void *lock_addr;
 		int times_locked;
+		enum ast_lock_type type;
 		/*! This thread is waiting on this lock */
 		unsigned int pending:1;
 	} locks[AST_MAX_LOCKS];
@@ -592,8 +593,8 @@
  */
 AST_THREADSTORAGE_CUSTOM(thread_lock_info, NULL, lock_info_destroy);
 
-void ast_store_lock_info(const char *filename, int line_num, 
-	const char *func, const char *lock_name, void *lock_addr)
+void ast_store_lock_info(enum ast_lock_type type, const char *filename,
+	int line_num, const char *func, const char *lock_name, void *lock_addr)
 {
 	struct thr_lock_info *lock_info;
 	int i;
@@ -625,6 +626,7 @@
 	lock_info->locks[i].lock_name = lock_name;
 	lock_info->locks[i].lock_addr = lock_addr;
 	lock_info->locks[i].times_locked = 1;
+	lock_info->locks[i].type = type;
 	lock_info->locks[i].pending = 1;
 	lock_info->num_locks++;
 
@@ -679,6 +681,20 @@
 	lock_info->num_locks--;
 
 	pthread_mutex_unlock(&lock_info->lock);
+}
+
+static const char *locktype2str(enum ast_lock_type type)
+{
+	switch (type) {
+	case AST_MUTEX:
+		return "MUTEX";
+	case AST_RDLOCK:
+		return "RDLOCK";
+	case AST_WRLOCK:
+		return "WRLOCK";
+	}
+
+	return "UNKNOWN";
 }
 
 static char *handle_show_locks(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
@@ -713,9 +729,11 @@
 			lock_info->thread_name);
 		pthread_mutex_lock(&lock_info->lock);
 		for (i = 0; i < lock_info->num_locks; i++) {
-			ast_cli(a->fd, "=== ---> %sLock #%d: %s %d %s %s %p (%d)\n", 
+			ast_cli(a->fd, "=== ---> %sLock #%d (%s): %s %d %s %s %p (%d)\n", 
 				lock_info->locks[i].pending ? "Waiting for " : "", i,
-				lock_info->locks[i].file, lock_info->locks[i].line_num,
+				lock_info->locks[i].file, 
+				locktype2str(lock_info->locks[i].type),
+				lock_info->locks[i].line_num,
 				lock_info->locks[i].func, lock_info->locks[i].lock_name,
 				lock_info->locks[i].lock_addr, 
 				lock_info->locks[i].times_locked);




More information about the asterisk-commits mailing list