[asterisk-commits] russell: branch russell/chan_refcount r82481 - in /team/russell/chan_refcount...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Sep 14 17:54:51 CDT 2007
Author: russell
Date: Fri Sep 14 17:54:51 2007
New Revision: 82481
URL: http://svn.digium.com/view/asterisk?view=rev&rev=82481
Log:
convert app_directed_pickup and update more docs
Modified:
team/russell/chan_refcount/apps/app_directed_pickup.c
team/russell/chan_refcount/include/asterisk/channel.h
Modified: team/russell/chan_refcount/apps/app_directed_pickup.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/apps/app_directed_pickup.c?view=diff&rev=82481&r1=82480&r2=82481
==============================================================================
--- team/russell/chan_refcount/apps/app_directed_pickup.c (original)
+++ team/russell/chan_refcount/apps/app_directed_pickup.c Fri Sep 14 17:54:51 2007
@@ -97,17 +97,26 @@
{
int res = -1;
struct ast_channel *target = NULL;
+ struct ast_channel_iterator *iter;
- while ((target = ast_channel_walk_locked(target))) {
+ if (!(iter = ast_channel_iterator_all_new()))
+ return -1;
+
+ while ((target = ast_channel_iterator_next(iter))) {
+ ast_channel_lock(target);
if ((!strcasecmp(target->macroexten, exten) || !strcasecmp(target->exten, exten)) &&
!strcasecmp(target->dialcontext, context) &&
can_pickup(target)) {
+ ast_channel_unlock(target);
res = pickup_do(chan, target);
- ast_channel_unlock(target);
+ ast_channel_unref(target);
break;
}
ast_channel_unlock(target);
+ ast_channel_unref(target);
}
+
+ ast_channel_iterator_destroy(iter);
return res;
}
@@ -118,17 +127,26 @@
int res = -1;
const char *tmp = NULL;
struct ast_channel *target = NULL;
+ struct ast_channel_iterator *iter;
- while ((target = ast_channel_walk_locked(target))) {
+ if (!(iter = ast_channel_iterator_all_new()))
+ return -1;
+
+ while ((target = ast_channel_iterator_next(iter))) {
+ ast_channel_lock(target);
if ((tmp = pbx_builtin_getvar_helper(target, PICKUPMARK)) &&
!strcasecmp(tmp, mark) &&
can_pickup(target)) {
+ ast_channel_unlock(target);
res = pickup_do(chan, target);
- ast_channel_unlock(target);
+ ast_channel_unref(target);
break;
}
ast_channel_unlock(target);
+ ast_channel_unref(target);
}
+
+ ast_channel_iterator_destroy(iter);
return res;
}
Modified: team/russell/chan_refcount/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/include/asterisk/channel.h?view=diff&rev=82481&r1=82480&r2=82481
==============================================================================
--- team/russell/chan_refcount/include/asterisk/channel.h (original)
+++ team/russell/chan_refcount/include/asterisk/channel.h Fri Sep 14 17:54:51 2007
@@ -655,18 +655,31 @@
*/
struct ast_channel *ast_channel_alloc(int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const int amaflag, const char *name_fmt, ...);
-/*! \brief Queue an outgoing frame */
+/*!
+ * \brief Queue an outgoing frame
+ *
+ * \note The channel does not need to be locked before calling this function.
+ */
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f);
-/*! \brief Queue a hangup frame */
+/*!
+ * \brief Queue a hangup frame
+ *
+ * \note The channel does not need to be locked before calling this function.
+ */
int ast_queue_hangup(struct ast_channel *chan);
/*!
- \brief Queue a control frame with payload
- \param chan channel to queue frame onto
- \param control type of control frame
- \return zero on success, non-zero on failure
-*/
+ * \brief Queue a control frame with payload
+ *
+ * \param chan channel to queue frame onto
+ * \param control type of control frame
+ *
+ * \note The channel does not need to be locked before calling this function.
+ *
+ * \retval zero on success
+ * \retval non-zero on failure
+ */
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control);
/*!
@@ -687,7 +700,9 @@
you should ensure that either your frames will never be expected to work
across systems, or that you always put your payload data into 'network byte
order' before calling this function.
-*/
+
+ \note The channel does not need to be locked before calling this function.
+ */
int ast_queue_control_data(struct ast_channel *chan, enum ast_control_frame_type control,
const void *data, size_t datalen);
@@ -813,11 +828,18 @@
*/
void ast_channel_setwhentohangup(struct ast_channel *chan, time_t offset);
-/*! \brief Answer a channel
+/*!
+ * \brief Answer a channel
+ *
* \param chan channel to answer
+ *
* This function answers a channel and handles all necessary call
* setup functions.
- * \return Returns 0 on success, non-zero on failure
+ *
+ * \note The channel passed does not need to be locked.
+ *
+ * \retval 0 on success
+ * \retval non-zero on failure
*/
int ast_answer(struct ast_channel *chan);
int __ast_answer(struct ast_channel *chan, unsigned int delay);
@@ -1115,15 +1137,21 @@
/* int ast_channel_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc); */
int ast_channel_bridge(struct ast_channel *c0,struct ast_channel *c1,struct ast_bridge_config *config, struct ast_frame **fo, struct ast_channel **rc);
-/*! \brief Weird function made for call transfers
+/*!
+ * \brief Weird function made for call transfers
+ *
* \param original channel to make a copy of
* \param clone copy of the original channel
+ *
* This is a very strange and freaky function used primarily for transfer. Suppose that
- "original" and "clone" are two channels in random situations. This function takes
- the guts out of "clone" and puts them into the "original" channel, then alerts the
- channel driver of the change, asking it to fixup any private information (like the
- p->owner pointer) that is affected by the change. The physical layer of the original
- channel is hung up. */
+ * "original" and "clone" are two channels in random situations. This function takes
+ * the guts out of "clone" and puts them into the "original" channel, then alerts the
+ * channel driver of the change, asking it to fixup any private information (like the
+ * p->owner pointer) that is affected by the change. The physical layer of the original
+ * channel is hung up.
+ *
+ * \note Neither channel passed here needs to be locked before calling this function.
+ */
int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clone);
/*! Gives the string form of a given cause code */
More information about the asterisk-commits
mailing list