[asterisk-commits] rmudgett: branch rmudgett/hangup_handlers r369032 - in /team/rmudgett/hangup_...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Jun 15 13:46:37 CDT 2012
Author: rmudgett
Date: Fri Jun 15 13:46:33 2012
New Revision: 369032
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=369032
Log:
Create hangup handlers container constructor/destructor and rename some variables.
Modified:
team/rmudgett/hangup_handlers/include/asterisk/pbx.h
team/rmudgett/hangup_handlers/main/channel.c
team/rmudgett/hangup_handlers/main/pbx.c
Modified: team/rmudgett/hangup_handlers/include/asterisk/pbx.h
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/hangup_handlers/include/asterisk/pbx.h?view=diff&rev=369032&r1=369031&r2=369032
==============================================================================
--- team/rmudgett/hangup_handlers/include/asterisk/pbx.h (original)
+++ team/rmudgett/hangup_handlers/include/asterisk/pbx.h Fri Jun 15 13:46:33 2012
@@ -392,6 +392,26 @@
int ast_pbx_hangup_handler_run(struct ast_channel *chan);
/*!
+ * \brief Init the hangup handler container on a channel.
+ * \since 11.0
+ *
+ * \param chan Channel to init the hangup handler container on.
+ *
+ * \return Nothing
+ */
+void ast_pbx_hangup_handler_init(struct ast_channel *chan);
+
+/*!
+ * \brief Destroy the hangup handler container on a channel.
+ * \since 11.0
+ *
+ * \param chan Channel to destroy the hangup handler container on.
+ *
+ * \return Nothing
+ */
+void ast_pbx_hangup_handler_destroy(struct ast_channel *chan);
+
+/*!
* \brief Add the given hangup handler to the channel.
* \since 11.0
*
Modified: team/rmudgett/hangup_handlers/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/hangup_handlers/main/channel.c?view=diff&rev=369032&r1=369031&r2=369032
==============================================================================
--- team/rmudgett/hangup_handlers/main/channel.c (original)
+++ team/rmudgett/hangup_handlers/main/channel.c Fri Jun 15 13:46:33 2012
@@ -1107,7 +1107,7 @@
headp = ast_channel_varshead(tmp);
AST_LIST_HEAD_INIT_NOLOCK(headp);
- AST_LIST_HEAD_INIT_NOLOCK(ast_channel_hangup_handlers(tmp));
+ ast_pbx_hangup_handler_init(tmp);
AST_LIST_HEAD_INIT_NOLOCK(ast_channel_datastores(tmp));
AST_LIST_HEAD_INIT_NOLOCK(ast_channel_autochans(tmp));
@@ -1184,7 +1184,7 @@
return NULL;
}
- AST_LIST_HEAD_INIT_NOLOCK(ast_channel_hangup_handlers(tmp));
+ ast_pbx_hangup_handler_init(tmp);
AST_LIST_HEAD_INIT_NOLOCK(ast_channel_datastores(tmp));
headp = ast_channel_varshead(tmp);
@@ -2193,7 +2193,6 @@
struct ast_var_t *vardata;
struct ast_frame *f;
struct varshead *headp;
- struct ast_hangup_handler *h_handler;
struct ast_datastore *datastore;
char device_name[AST_CHANNEL_NAME];
struct ast_callid *callid;
@@ -2203,12 +2202,9 @@
ast_cel_check_retire_linkedid(chan);
}
+ ast_pbx_hangup_handler_destroy(chan);
+
ast_channel_lock(chan);
-
- /* Get rid of each of the hangup handlers on the channel */
- while ((h_handler = AST_LIST_REMOVE_HEAD(ast_channel_hangup_handlers(chan), node))) {
- ast_free(h_handler);
- }
/* Get rid of each of the data stores on the channel */
while ((datastore = AST_LIST_REMOVE_HEAD(ast_channel_datastores(chan), entry)))
@@ -2327,15 +2323,11 @@
static void ast_dummy_channel_destructor(void *obj)
{
struct ast_channel *chan = obj;
- struct ast_hangup_handler *h_handler;
struct ast_datastore *datastore;
struct ast_var_t *vardata;
struct varshead *headp;
- /* Get rid of each of the hangup handlers on the channel (Just in case) */
- while ((h_handler = AST_LIST_REMOVE_HEAD(ast_channel_hangup_handlers(chan), node))) {
- ast_free(h_handler);
- }
+ ast_pbx_hangup_handler_destroy(chan);
/* Get rid of each of the data stores on the channel */
while ((datastore = AST_LIST_REMOVE_HEAD(ast_channel_datastores(chan), entry))) {
Modified: team/rmudgett/hangup_handlers/main/pbx.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/hangup_handlers/main/pbx.c?view=diff&rev=369032&r1=369031&r2=369032
==============================================================================
--- team/rmudgett/hangup_handlers/main/pbx.c (original)
+++ team/rmudgett/hangup_handlers/main/pbx.c Fri Jun 15 13:46:33 2012
@@ -5406,12 +5406,12 @@
/* BUGBUG need to examine all ast_bridge_call() to see about calling ast_pbx_hangup_handler_run(). */
int ast_pbx_hangup_handler_run(struct ast_channel *chan)
{
- struct ast_hangup_handler_list *list;
+ struct ast_hangup_handler_list *handlers;
struct ast_hangup_handler *h_handler;
ast_channel_lock(chan);
- list = ast_channel_hangup_handlers(chan);
- if (AST_LIST_EMPTY(list)) {
+ handlers = ast_channel_hangup_handlers(chan);
+ if (AST_LIST_EMPTY(handlers)) {
ast_channel_unlock(chan);
return 0;
}
@@ -5427,8 +5427,8 @@
ast_softhangup_nolock(chan, AST_SOFTHANGUP_APPUNLOAD);
for (;;) {
- list = ast_channel_hangup_handlers(chan);
- h_handler = AST_LIST_REMOVE_HEAD(list, node);
+ handlers = ast_channel_hangup_handlers(chan);
+ h_handler = AST_LIST_REMOVE_HEAD(handlers, node);
if (!h_handler) {
ast_channel_unlock(chan);
break;
@@ -5451,9 +5451,33 @@
return 1;
}
+void ast_pbx_hangup_handler_init(struct ast_channel *chan)
+{
+ struct ast_hangup_handler_list *handlers;
+
+ handlers = ast_channel_hangup_handlers(chan);
+ AST_LIST_HEAD_INIT_NOLOCK(handlers);
+}
+
+void ast_pbx_hangup_handler_destroy(struct ast_channel *chan)
+{
+ struct ast_hangup_handler_list *handlers;
+ struct ast_hangup_handler *h_handler;
+
+ ast_channel_lock(chan);
+
+ /* Get rid of each of the hangup handlers on the channel */
+ handlers = ast_channel_hangup_handlers(chan);
+ while ((h_handler = AST_LIST_REMOVE_HEAD(handlers, node))) {
+ ast_free(h_handler);
+ }
+
+ ast_channel_unlock(chan);
+}
+
void ast_pbx_hangup_handler_add(struct ast_channel *chan, const char *handler)
{
- struct ast_hangup_handler_list *list;
+ struct ast_hangup_handler_list *handlers;
struct ast_hangup_handler *h_handler;
const char *expanded_handler;
@@ -5475,8 +5499,8 @@
ast_channel_lock(chan);
- list = ast_channel_hangup_handlers(chan);
- AST_LIST_INSERT_HEAD(list, h_handler, node);
+ handlers = ast_channel_hangup_handlers(chan);
+ AST_LIST_INSERT_HEAD(handlers, h_handler, node);
manager_event(EVENT_FLAG_CALL, "HangupHandlerAdd",
"Channel: %s\r\n"
@@ -5517,13 +5541,13 @@
*/
static void ast_pbx_hangup_handler_show(int fd, struct ast_channel *chan)
{
- struct ast_hangup_handler_list *list;
+ struct ast_hangup_handler_list *handlers;
struct ast_hangup_handler *h_handler;
int first = 1;
ast_channel_lock(chan);
- list = ast_channel_hangup_handlers(chan);
- AST_LIST_TRAVERSE(list, h_handler, node) {
+ handlers = ast_channel_hangup_handlers(chan);
+ AST_LIST_TRAVERSE(handlers, h_handler, node) {
ast_cli(fd, HANDLER_FORMAT, first ? ast_channel_name(chan) : "", h_handler->args);
first = 0;
}
More information about the asterisk-commits
mailing list