summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bridges/bridge_native_rtp.c5
-rw-r--r--main/cdr.c36
2 files changed, 27 insertions, 14 deletions
diff --git a/bridges/bridge_native_rtp.c b/bridges/bridge_native_rtp.c
index 122c132d6..d490183ff 100644
--- a/bridges/bridge_native_rtp.c
+++ b/bridges/bridge_native_rtp.c
@@ -755,7 +755,7 @@ static int native_rtp_bridge_compatible(struct ast_bridge *bridge)
static int native_rtp_bridge_framehook_attach(struct ast_bridge_channel *bridge_channel)
{
struct native_rtp_bridge_channel_data *data = bridge_channel->tech_pvt;
- static struct ast_framehook_interface hook = {
+ struct ast_framehook_interface hook = {
.version = AST_FRAMEHOOK_INTERFACE_VERSION,
.event_cb = native_rtp_framehook,
.destroy_cb = __ao2_cleanup,
@@ -773,9 +773,10 @@ static int native_rtp_bridge_framehook_attach(struct ast_bridge_channel *bridge_
ast_debug(2, "Bridge '%s'. Attaching hook data %p to '%s'\n",
bridge_channel->bridge->uniqueid, data, ast_channel_name(bridge_channel->chan));
- ast_channel_lock(bridge_channel->chan);
/* We're giving 1 ref to the framehook and keeping the one from the alloc for ourselves */
hook.data = ao2_bump(data->hook_data);
+
+ ast_channel_lock(bridge_channel->chan);
data->hook_data->id = ast_framehook_attach(bridge_channel->chan, &hook);
ast_channel_unlock(bridge_channel->chan);
if (data->hook_data->id < 0) {
diff --git a/main/cdr.c b/main/cdr.c
index 0b571fe0e..df5ce5497 100644
--- a/main/cdr.c
+++ b/main/cdr.c
@@ -2094,7 +2094,12 @@ static void handle_dial_message(void *data, struct stasis_subscription *sub, str
if (!peer && !caller) {
return;
}
- if (filter_channel_snapshot(peer) || (caller && filter_channel_snapshot(caller))) {
+
+ if (peer && filter_channel_snapshot(peer)) {
+ return;
+ }
+
+ if (caller && filter_channel_snapshot(caller)) {
return;
}
@@ -2868,32 +2873,39 @@ int ast_cdr_backend_unsuspend(const char *name)
int ast_cdr_register(const char *name, const char *desc, ast_cdrbe be)
{
- struct cdr_beitem *i = NULL;
+ struct cdr_beitem *i;
+ struct cdr_beitem *cur;
- if (!name)
+ if (!name) {
return -1;
+ }
if (!be) {
ast_log(LOG_WARNING, "CDR engine '%s' lacks backend\n", name);
+
+ return -1;
+ }
+
+ i = ast_calloc(1, sizeof(*i));
+ if (!i) {
return -1;
}
+ i->be = be;
+ ast_copy_string(i->name, name, sizeof(i->name));
+ ast_copy_string(i->desc, desc, sizeof(i->desc));
+
AST_RWLIST_WRLOCK(&be_list);
- AST_RWLIST_TRAVERSE(&be_list, i, list) {
- if (!strcasecmp(name, i->name)) {
+ AST_RWLIST_TRAVERSE(&be_list, cur, list) {
+ if (!strcasecmp(name, cur->name)) {
ast_log(LOG_WARNING, "Already have a CDR backend called '%s'\n", name);
AST_RWLIST_UNLOCK(&be_list);
+ ast_free(i);
+
return -1;
}
}
- if (!(i = ast_calloc(1, sizeof(*i))))
- return -1;
-
- i->be = be;
- ast_copy_string(i->name, name, sizeof(i->name));
- ast_copy_string(i->desc, desc, sizeof(i->desc));
-
AST_RWLIST_INSERT_HEAD(&be_list, i, list);
AST_RWLIST_UNLOCK(&be_list);