void ast_cel_check_retire_linkedid(struct ast_channel *chan) { const char *linkedid = chan->linkedid; struct channel_find_data find_dat; /* make sure we need to do all this work */ if (!ast_strlen_zero(linkedid) && ast_cel_track_event(AST_CEL_LINKEDID_END)) { struct ast_channel *tmp = NULL; find_dat.chan = chan; find_dat.linkedid = linkedid; if ((tmp = ast_channel_callback(linkedid_match, NULL, &find_dat, 0))) { tmp = ast_channel_unref(tmp); } else { ast_cel_report_event(chan, AST_CEL_LINKEDID_END, NULL, NULL, NULL); } } }
/* called whenever a channel is destroyed or a linkedid is changed to * potentially emit a CEL_LINKEDID_END event */ void ast_cel_check_retire_linkedid(struct ast_channel *chan) { const char *linkedid = ast_channel_linkedid(chan); char *lid; /* make sure we need to do all this work */ if (ast_strlen_zero(linkedid) || !ast_cel_track_event(AST_CEL_LINKEDID_END)) { return; } if (!(lid = ao2_find(linkedids, (void *) linkedid, OBJ_POINTER))) { ast_log(LOG_ERROR, "Something weird happened, couldn't find linkedid %s\n", linkedid); return; } /* We have a ref for each channel with this linkedid, the link and the above find, so if * before unreffing the channel we have a refcount of 3, we're done. Unlink and report. */ if (ao2_ref(lid, -1) == 3) { ao2_unlink(linkedids, lid); ast_cel_report_event(chan, AST_CEL_LINKEDID_END, NULL, NULL, NULL); } ao2_ref(lid, -1); }