diff options
Diffstat (limited to 'main')
-rw-r--r-- | main/ast_expr2.c | 2 | ||||
-rw-r--r-- | main/ast_expr2.y | 2 | ||||
-rw-r--r-- | main/astobj2_hash.c | 4 | ||||
-rw-r--r-- | main/astobj2_rbtree.c | 2 | ||||
-rw-r--r-- | main/bridge_channel.c | 9 | ||||
-rw-r--r-- | main/features.c | 6 | ||||
-rw-r--r-- | main/pbx.c | 19 | ||||
-rw-r--r-- | main/stasis_endpoints.c | 34 | ||||
-rw-r--r-- | main/stasis_system.c | 6 | ||||
-rw-r--r-- | main/threadpool.c | 6 | ||||
-rw-r--r-- | main/translate.c | 2 |
11 files changed, 66 insertions, 26 deletions
diff --git a/main/ast_expr2.c b/main/ast_expr2.c index 781abd95a..a3c715ac1 100644 --- a/main/ast_expr2.c +++ b/main/ast_expr2.c @@ -3672,6 +3672,8 @@ op_tildetilde (struct val *a, struct val *b) vs = malloc(strlen(a->u.s)+strlen(b->u.s)+1); if (vs == NULL) { ast_log(LOG_WARNING, "malloc() failed\n"); + free_value(a); + free_value(b); return NULL; } diff --git a/main/ast_expr2.y b/main/ast_expr2.y index 913bc2662..4f6087773 100644 --- a/main/ast_expr2.y +++ b/main/ast_expr2.y @@ -1665,6 +1665,8 @@ op_tildetilde (struct val *a, struct val *b) vs = malloc(strlen(a->u.s)+strlen(b->u.s)+1); if (vs == NULL) { ast_log(LOG_WARNING, "malloc() failed\n"); + free_value(a); + free_value(b); return NULL; } diff --git a/main/astobj2_hash.c b/main/astobj2_hash.c index 1cd6ee249..341ff79e0 100644 --- a/main/astobj2_hash.c +++ b/main/astobj2_hash.c @@ -298,7 +298,7 @@ static enum ao2_container_insert hash_ao2_insert_node(struct ao2_container_hash break; case AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE: SWAP(cur->common.obj, node->common.obj); - ao2_t_ref(node, -1, "Discard the new node."); + __ao2_ref(node, -1); return AO2_CONTAINER_INSERT_NODE_OBJ_REPLACED; } } @@ -331,7 +331,7 @@ static enum ao2_container_insert hash_ao2_insert_node(struct ao2_container_hash break; case AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE: SWAP(cur->common.obj, node->common.obj); - ao2_t_ref(node, -1, "Discard the new node."); + __ao2_ref(node, -1); return AO2_CONTAINER_INSERT_NODE_OBJ_REPLACED; } } diff --git a/main/astobj2_rbtree.c b/main/astobj2_rbtree.c index d8195d47f..a8d5e3ac1 100644 --- a/main/astobj2_rbtree.c +++ b/main/astobj2_rbtree.c @@ -1267,7 +1267,7 @@ static enum ao2_container_insert rb_ao2_insert_node(struct ao2_container_rbtree break; case AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE: SWAP(cur->common.obj, node->common.obj); - ao2_t_ref(node, -1, "Don't need the new node."); + __ao2_ref(node, -1); return AO2_CONTAINER_INSERT_NODE_OBJ_REPLACED; } diff --git a/main/bridge_channel.c b/main/bridge_channel.c index 543988dde..2fafdf990 100644 --- a/main/bridge_channel.c +++ b/main/bridge_channel.c @@ -1543,8 +1543,13 @@ static void testsuite_notify_feature_success(struct ast_channel *chan, const cha { #ifdef TEST_FRAMEWORK char *feature = "unknown"; - struct ast_featuremap_config *featuremap = ast_get_chan_featuremap_config(chan); - struct ast_features_xfer_config *xfer = ast_get_chan_features_xfer_config(chan); + struct ast_featuremap_config *featuremap; + struct ast_features_xfer_config *xfer; + + ast_channel_lock(chan); + featuremap = ast_get_chan_featuremap_config(chan); + xfer = ast_get_chan_features_xfer_config(chan); + ast_channel_unlock(chan); if (featuremap) { if (!strcmp(dtmf, featuremap->blindxfer)) { diff --git a/main/features.c b/main/features.c index b96cbd68c..00010514c 100644 --- a/main/features.c +++ b/main/features.c @@ -767,8 +767,8 @@ static int action_bridge(struct mansession *s, const struct message *m) astman_send_error(s, m, buf); return 0; } - xfer_cfg_a = ast_get_chan_features_xfer_config(chana); ast_channel_lock(chana); + xfer_cfg_a = ast_get_chan_features_xfer_config(chana); chana_exten = ast_strdupa(ast_channel_exten(chana)); chana_context = ast_strdupa(ast_channel_context(chana)); chana_priority = ast_channel_priority(chana); @@ -783,8 +783,8 @@ static int action_bridge(struct mansession *s, const struct message *m) astman_send_error(s, m, buf); return 0; } - xfer_cfg_b = ast_get_chan_features_xfer_config(chanb); ast_channel_lock(chanb); + xfer_cfg_b = ast_get_chan_features_xfer_config(chanb); chanb_exten = ast_strdupa(ast_channel_exten(chanb)); chanb_context = ast_strdupa(ast_channel_context(chanb)); chanb_priority = ast_channel_priority(chanb); @@ -1098,7 +1098,9 @@ static int bridge_exec(struct ast_channel *chan, const char *data) goto done; } + ast_channel_lock(current_dest_chan); xfer_cfg = ast_get_chan_features_xfer_config(current_dest_chan); + ast_channel_unlock(current_dest_chan); bridge_add_failed = ast_bridge_add_channel(bridge, current_dest_chan, peer_features, ast_test_flag(&opts, BRIDGE_OPT_PLAYTONE), xfer_cfg ? xfer_cfg->xfersound : NULL); diff --git a/main/pbx.c b/main/pbx.c index 6b0069c06..5bafee337 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -4682,6 +4682,13 @@ static struct ast_context *find_context_locked(const char *context) return c; } +/*! \brief Free an ast_include and associated data. */ +static void include_free(struct ast_include *include) +{ + ast_destroy_timing(&(include->timing)); + ast_free(include); +} + /*! * \brief Remove included contexts. * This function locks contexts list by &conlist, search for the right context @@ -4729,8 +4736,7 @@ int ast_context_remove_include2(struct ast_context *con, const char *include, co else con->includes = i->next; /* free include and return */ - ast_destroy_timing(&(i->timing)); - ast_free(i); + include_free(i); ret = 0; break; } @@ -6481,8 +6487,7 @@ int ast_context_add_include2(struct ast_context *con, const char *value, /* ... go to last include and check if context is already included too... */ for (i = con->includes; i; i = i->next) { if (!strcasecmp(i->name, new_include->name)) { - ast_destroy_timing(&(new_include->timing)); - ast_free(new_include); + include_free(new_include); ast_unlock_context(con); errno = EEXIST; return -1; @@ -7706,7 +7711,7 @@ static void __ast_internal_context_destroy( struct ast_context *con) for (tmpi = tmp->includes; tmpi; ) { /* Free includes */ struct ast_include *tmpil = tmpi; tmpi = tmpi->next; - ast_free(tmpil); + include_free(tmpil); } for (ipi = tmp->ignorepats; ipi; ) { /* Free ignorepats */ struct ast_ignorepat *ipl = ipi; @@ -7800,12 +7805,12 @@ void __ast_context_destroy(struct ast_context *list, struct ast_hashtab *context if (pi) { pi->next = i->next; /* free include */ - ast_free(i); + include_free(i); continue; /* don't change pi */ } else { tmp->includes = i->next; /* free include */ - ast_free(i); + include_free(i); continue; /* don't change pi */ } } diff --git a/main/stasis_endpoints.c b/main/stasis_endpoints.c index c31714bf4..8cc60506c 100644 --- a/main/stasis_endpoints.c +++ b/main/stasis_endpoints.c @@ -253,6 +253,7 @@ static struct ast_json *contactstatus_to_json(struct stasis_message *msg, const struct ast_endpoint_blob *obj = stasis_message_data(msg); struct ast_json *json_endpoint; struct ast_json *json_final; + const char *rtt; const struct timeval *tv = stasis_message_timestamp(msg); json_endpoint = ast_endpoint_snapshot_to_json(obj->snapshot, NULL); @@ -260,15 +261,30 @@ static struct ast_json *contactstatus_to_json(struct stasis_message *msg, const return NULL; } - json_final = ast_json_pack("{s: s, s: o, s: o, s: { s: s, s: s, s: s, s: s } } ", - "type", "ContactStatusChange", - "timestamp", ast_json_timeval(*tv, NULL), - "endpoint", json_endpoint, - "contact_info", - "uri", ast_json_string_get(ast_json_object_get(obj->blob, "uri")), - "contact_status", ast_json_string_get(ast_json_object_get(obj->blob, "contact_status")), - "aor", ast_json_string_get(ast_json_object_get(obj->blob, "aor")), - "roundtrip_usec", ast_json_string_get(ast_json_object_get(obj->blob, "roundtrip_usec"))); + /* The roundtrip time is optional. */ + rtt = ast_json_string_get(ast_json_object_get(obj->blob, "roundtrip_usec")); + if (!ast_strlen_zero(rtt)) { + json_final = ast_json_pack("{s: s, s: o, s: o, s: { s: s, s: s, s: s, s: s } } ", + "type", "ContactStatusChange", + "timestamp", ast_json_timeval(*tv, NULL), + "endpoint", json_endpoint, + "contact_info", + "uri", ast_json_string_get(ast_json_object_get(obj->blob, "uri")), + "contact_status", ast_json_string_get(ast_json_object_get(obj->blob, + "contact_status")), + "aor", ast_json_string_get(ast_json_object_get(obj->blob, "aor")), + "roundtrip_usec", rtt); + } else { + json_final = ast_json_pack("{s: s, s: o, s: o, s: { s: s, s: s, s: s } } ", + "type", "ContactStatusChange", + "timestamp", ast_json_timeval(*tv, NULL), + "endpoint", json_endpoint, + "contact_info", + "uri", ast_json_string_get(ast_json_object_get(obj->blob, "uri")), + "contact_status", ast_json_string_get(ast_json_object_get(obj->blob, + "contact_status")), + "aor", ast_json_string_get(ast_json_object_get(obj->blob, "aor"))); + } if (!json_final) { ast_json_unref(json_endpoint); } diff --git a/main/stasis_system.c b/main/stasis_system.c index e232b8e8a..67970bd74 100644 --- a/main/stasis_system.c +++ b/main/stasis_system.c @@ -115,6 +115,7 @@ STASIS_MESSAGE_TYPE_DEFN(ast_cc_failure_type, STASIS_MESSAGE_TYPE_DEFN(ast_cc_monitorfailed_type, .to_ami = cc_monitorfailed_to_ami, ); +STASIS_MESSAGE_TYPE_DEFN(ast_cluster_discovery_type); void ast_system_publish_registry(const char *channeltype, const char *username, const char *domain, const char *status, const char *cause) { @@ -362,6 +363,7 @@ static void stasis_system_cleanup(void) STASIS_MESSAGE_TYPE_CLEANUP(ast_cc_recallcomplete_type); STASIS_MESSAGE_TYPE_CLEANUP(ast_cc_failure_type); STASIS_MESSAGE_TYPE_CLEANUP(ast_cc_monitorfailed_type); + STASIS_MESSAGE_TYPE_CLEANUP(ast_cluster_discovery_type); } /*! \brief Initialize the system level items for \ref stasis */ @@ -422,5 +424,9 @@ int ast_stasis_system_init(void) return -1; } + if (STASIS_MESSAGE_TYPE_INIT(ast_cluster_discovery_type) != 0) { + return -1; + } + return 0; } diff --git a/main/threadpool.c b/main/threadpool.c index 9cd33ab1a..6240b7329 100644 --- a/main/threadpool.c +++ b/main/threadpool.c @@ -1384,10 +1384,12 @@ struct ast_taskprocessor *ast_threadpool_serializer_group(const char *name, ao2_ref(ser, -1); return NULL; } - /* ser ref transferred to listener */ tps = ast_taskprocessor_create_with_listener(name, listener); - if (tps && shutdown_group) { + if (!tps) { + /* ser ref transferred to listener but not cleaned without tps */ + ao2_ref(ser, -1); + } else if (shutdown_group) { serializer_shutdown_group_inc(shutdown_group); } diff --git a/main/translate.c b/main/translate.c index 6a39bac1a..73e03a82e 100644 --- a/main/translate.c +++ b/main/translate.c @@ -494,7 +494,7 @@ struct ast_trans_pvt *ast_translator_build_path(struct ast_format *dst, struct a AST_RWLIST_UNLOCK(&translators); return NULL; } - if ((t->dst_codec.sample_rate == ast_format_get_sample_rate(dst)) && (t->dst_codec.type == ast_format_get_type(dst)) && (!strcmp(t->dst_codec.name, ast_format_get_name(dst)))) { + if ((t->dst_codec.sample_rate == ast_format_get_sample_rate(dst)) && (t->dst_codec.type == ast_format_get_type(dst))) { explicit_dst = dst; } if (!(cur = newpvt(t, explicit_dst))) { |