[asterisk-commits] mmichelson: branch group/CCSS r215918 - in /team/group/CCSS: include/asterisk...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Sep 3 08:28:08 CDT 2009
Author: mmichelson
Date: Thu Sep 3 08:28:03 2009
New Revision: 215918
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=215918
Log:
Fix a logic bug in the list of monitor links.
Since each link is a part of two lists, there need
to be two AST_LIST_ENTRY fields per monitor link.
The way it was written previously, there would be
some bad problems, including memory leaks.
Modified:
team/group/CCSS/include/asterisk/ccss.h
team/group/CCSS/main/ccss.c
Modified: team/group/CCSS/include/asterisk/ccss.h
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/CCSS/include/asterisk/ccss.h?view=diff&rev=215918&r1=215917&r2=215918
==============================================================================
--- team/group/CCSS/include/asterisk/ccss.h (original)
+++ team/group/CCSS/include/asterisk/ccss.h Thu Sep 3 08:28:03 2009
@@ -466,7 +466,14 @@
* to
*/
const unsigned int core_id;
- AST_LIST_ENTRY(ast_cc_monitor_link) next;
+ /*!
+ * Why are there two AST_LIST_ENTRY fields in this
+ * struct? The reason is that each link is in a list
+ * parent links of one monitor, and in a list of child
+ * links for another.
+ */
+ AST_LIST_ENTRY(ast_cc_monitor_link) next_child;
+ AST_LIST_ENTRY(ast_cc_monitor_link) next_parent;
};
/*!
Modified: team/group/CCSS/main/ccss.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/CCSS/main/ccss.c?view=diff&rev=215918&r1=215917&r2=215918
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Thu Sep 3 08:28:03 2009
@@ -861,8 +861,8 @@
new_link->parent = parent;
ao2_ref(new_link->child, +1);
ao2_ref(new_link->parent, +1);
- AST_LIST_INSERT_TAIL(&parent->child_links, new_link, next);
- AST_LIST_INSERT_TAIL(&new_monitor->parent_links, new_link, next);
+ AST_LIST_INSERT_TAIL(&parent->child_links, new_link, next_child);
+ AST_LIST_INSERT_TAIL(&new_monitor->parent_links, new_link, next_parent);
ast_log(LOG_NOTICE, "Created link with parent %s and child %s\n", new_link->parent->name, new_link->child->name);
ao2_ref(new_monitor, -1);
return new_monitor;
@@ -950,17 +950,17 @@
static void prune_links(struct ast_cc_monitor *monitor, const int core_id, struct ast_cc_monitor_link *link_parent)
{
struct ast_cc_monitor_link *link_iter;
- AST_LIST_TRAVERSE_SAFE_BEGIN(&monitor->child_links, link_iter, next) {
+ AST_LIST_TRAVERSE_SAFE_BEGIN(&monitor->child_links, link_iter, next_child) {
if (link_iter->core_id == core_id) {
prune_links(link_iter->child, core_id, link_iter);
- AST_LIST_REMOVE_CURRENT(next);
+ AST_LIST_REMOVE_CURRENT(next_child);
destroy_link(link_iter);
}
}
AST_LIST_TRAVERSE_SAFE_END;
if (link_parent) {
- AST_LIST_REMOVE(&monitor->parent_links, link_parent, next);
+ AST_LIST_REMOVE(&monitor->parent_links, link_parent, next_parent);
}
if (AST_LIST_EMPTY(&monitor->parent_links) &&
AST_LIST_EMPTY(&monitor->child_links)) {
@@ -1159,7 +1159,7 @@
static int cc_extension_monitor_request_cc(struct ast_cc_monitor *monitor, const int core_id)
{
struct ast_cc_monitor_link *link_iter;
- AST_LIST_TRAVERSE(&monitor->child_links, link_iter, next) {
+ AST_LIST_TRAVERSE(&monitor->child_links, link_iter, next_child) {
ast_assert(link_iter->child != NULL);
ast_assert(link_iter->child->callbacks != NULL);
link_iter->child->callbacks->request_cc(link_iter->child, core_id);
@@ -1177,7 +1177,7 @@
static int cc_extension_monitor_suspend(struct ast_cc_monitor *monitor, const int core_id)
{
struct ast_cc_monitor_link *link_iter;
- AST_LIST_TRAVERSE(&monitor->child_links, link_iter, next) {
+ AST_LIST_TRAVERSE(&monitor->child_links, link_iter, next_child) {
ast_assert(link_iter->child != NULL);
ast_assert(link_iter->child->callbacks != NULL);
link_iter->child->callbacks->suspend(link_iter->child, core_id);
@@ -1194,7 +1194,7 @@
static int cc_extension_monitor_unsuspend(struct ast_cc_monitor *monitor, const int core_id)
{
struct ast_cc_monitor_link *link_iter;
- AST_LIST_TRAVERSE(&monitor->child_links, link_iter, next) {
+ AST_LIST_TRAVERSE(&monitor->child_links, link_iter, next_child) {
ast_assert(link_iter->child != NULL);
ast_assert(link_iter->child->callbacks != NULL);
link_iter->child->callbacks->unsuspend(link_iter->child, core_id);
More information about the asterisk-commits
mailing list