diff options
Diffstat (limited to 'main')
-rw-r--r-- | main/pbx.c | 19 | ||||
-rw-r--r-- | main/stasis_endpoints.c | 34 | ||||
-rw-r--r-- | main/stasis_system.c | 6 |
3 files changed, 43 insertions, 16 deletions
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; } |