All pastes #1245326 Raw Edit

clueless

public text v1 · immutable
#1245326 ·published 2008-11-04 21:59 UTC
rendered paste body
Index: include/asterisk/channel.h===================================================================--- include/asterisk/channel.h	(revision 154189)+++ include/asterisk/channel.h	(working copy)@@ -1177,6 +1177,9 @@ struct ast_channel *ast_walk_channel_by_exten_locked(const struct ast_channel *chan, const char *exten, 						     const char *context); +/*! \brief Search for a channel based on the specified filter (first match) and lock it */+struct ast_channel *ast_channel_search_locked(int (*filter)(struct ast_channel *));+ /*! ! \brief Waits for a digit  * \param c channel to wait for a digit on  * \param ms how many milliseconds to waitIndex: main/channel.c===================================================================--- main/channel.c	(revision 154189)+++ main/channel.c	(working copy)@@ -1226,6 +1226,24 @@ 	return channel_find_locked(chan, NULL, 0, context, exten); } +/*! \brief Search for a channel based on the specified filter (first match) and lock it */+struct ast_channel *ast_channel_search_locked(int (*filter)(struct ast_channel *))+{+	struct ast_channel *c;++	AST_RWLIST_RDLOCK(&channels);+	AST_RWLIST_TRAVERSE(&channels, c, chan_list) {+		if (filter(c)) {+			ast_channel_lock(c);+			AST_RWLIST_UNLOCK(&channels);+			return c;+		}+	}+	AST_RWLIST_UNLOCK(&channels);++	return NULL;+}+ /*! \brief Wait, look for hangups and condition arg */ int ast_safe_sleep_conditional(struct ast_channel *chan, int ms, int (*cond)(void*), void *data) {