Change the behavior of ao2_link(). Previously, in inherited a reference.

Now, it automatically increases the reference count to reflect the reference
that is now held by the container.

This was done to be more consistent with ao2_unlink(), which automatically
releases the reference held by the container.  It also makes it so it is
no longer possible for a pointer to be invalid after ao2_link() returns.


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@90348 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Russell Bryant
2007-11-30 19:26:04 +00:00
parent 82757dfaa1
commit 1f8caa100d
5 changed files with 23 additions and 18 deletions

View File

@@ -1069,6 +1069,8 @@ static void rt_handle_member_record(struct call_queue *q, char *interface, const
m->realtime = 1;
add_to_interfaces(interface);
ao2_link(q->members, m);
ao2_ref(m, -1);
m = NULL;
q->membercount++;
}
} else {
@@ -3036,6 +3038,8 @@ static int add_to_queue(const char *queuename, const char *interface, const char
if ((new_member = create_queue_member(interface, membername, penalty, paused))) {
new_member->dynamic = 1;
ao2_link(q->members, new_member);
ao2_ref(new_member, -1);
new_member = NULL;
q->membercount++;
manager_event(EVENT_FLAG_AGENT, "QueueMemberAdded",
"Queue: %s\r\n"
@@ -4021,6 +4025,8 @@ static int reload_queues(void)
newm = create_queue_member(interface, membername, penalty, cur ? cur->paused : 0);
ao2_link(q->members, newm);
ao2_ref(newm, -1);
newm = NULL;
if (cur)
ao2_ref(cur, -1);