Merge "StatsD: Add res_statsd compatibility"
authorJoshua Colp <jcolp@digium.com>
Wed, 4 Nov 2015 23:47:09 +0000 (17:47 -0600)
committerGerrit Code Review <gerrit2@gerrit.digium.api>
Wed, 4 Nov 2015 23:47:09 +0000 (17:47 -0600)
Makefile
build_tools/make_version_c
include/asterisk/ast_version.h
main/asterisk.c
main/dial.c
main/stasis_endpoints.c
res/res_pjsip/location.c
res/res_pjsip/pjsip_configuration.c

index 5bc6570..4b1c57b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -399,7 +399,7 @@ defaults.h: makeopts .lastclean build_tools/make_defaults_h
        @cmp -s $@.tmp $@ || mv $@.tmp $@
        @rm -f $@.tmp
 
-main/version.c: FORCE .lastclean
+main/version.c: FORCE menuselect.makeopts .lastclean
        @build_tools/make_version_c > $@.tmp
        @cmp -s $@.tmp $@ || mv $@.tmp $@
        @rm -f $@.tmp
index 3fea6ce..fcbd94e 100755 (executable)
@@ -1,4 +1,7 @@
 #!/bin/sh
+
+GREP=${GREP:-grep}
+
 if test ! -f .flavor ; then
     EXTRA=""
 elif test ! -f .version ; then
@@ -9,6 +12,21 @@ else
     aadkflavor=`cat .flavor`
     EXTRA=" (${aadkflavor} ${aadkver})"
 fi
+
+if ${GREP} "AST_DEVMODE" makeopts | ${GREP} -q "yes"
+then
+       BUILDOPTS="AST_DEVMODE"
+fi
+
+TMP=`${GREP} -e "^MENUSELECT_CFLAGS" menuselect.makeopts | sed 's/MENUSELECT_CFLAGS\=//g' | sed 's/-D//g'`
+for x in ${TMP}; do
+       if test "x${BUILDOPTS}" != "x" ; then
+               BUILDOPTS="${BUILDOPTS}, ${x}"
+       else
+               BUILDOPTS="${x}"
+       fi
+done
+
 cat << END
 /*
  * version.c
@@ -23,6 +41,8 @@ static const char asterisk_version[] = "${ASTERISKVERSION}${EXTRA}";
 
 static const char asterisk_version_num[] = "${ASTERISKVERSIONNUM}";
 
+static const char asterisk_build_opts[] = "${BUILDOPTS}";
+
 const char *ast_get_version(void)
 {
        return asterisk_version;
@@ -33,4 +53,9 @@ const char *ast_get_version_num(void)
        return asterisk_version_num;
 }
 
+const char *ast_get_build_opts(void)
+{
+       return asterisk_build_opts;
+}
+
 END
index 51ff481..1ceac30 100644 (file)
@@ -41,4 +41,7 @@ const char *ast_get_version(void);
  */
 const char *ast_get_version_num(void);
 
+/*! Retreive the Asterisk build options */
+const char *ast_get_build_opts(void);
+
 #endif /* __AST_VERSION_H */
index 4660bf9..e0a87d6 100644 (file)
@@ -601,7 +601,7 @@ static char *handle_show_settings(struct ast_cli_entry *e, int cmd, struct ast_c
        ast_cli(a->fd, "\nPBX Core settings\n");
        ast_cli(a->fd, "-----------------\n");
        ast_cli(a->fd, "  Version:                     %s\n", ast_get_version());
-       ast_cli(a->fd, "  Build Options:               %s\n", S_OR(AST_BUILDOPTS, "(none)"));
+       ast_cli(a->fd, "  Build Options:               %s\n", S_OR(ast_get_build_opts(), "(none)"));
        if (ast_option_maxcalls)
                ast_cli(a->fd, "  Maximum calls:               %d (Current %d)\n", ast_option_maxcalls, ast_active_channels());
        else
index 34d2f70..127f327 100644 (file)
@@ -295,6 +295,7 @@ static int begin_dial_prerun(struct ast_dial_channel *channel, struct ast_channe
        char numsubst[AST_MAX_EXTENSION];
        struct ast_format_cap *cap_all_audio = NULL;
        struct ast_format_cap *cap_request;
+       struct ast_format_cap *requester_cap = NULL;
        struct ast_assigned_ids assignedids = {
                .uniqueid = channel->assignedid1,
                .uniqueid2 = channel->assignedid2,
@@ -305,6 +306,7 @@ static int begin_dial_prerun(struct ast_dial_channel *channel, struct ast_channe
 
                ast_channel_lock(chan);
                max_forwards = ast_max_forwards_get(chan);
+               requester_cap = ao2_bump(ast_channel_nativeformats(chan));
                ast_channel_unlock(chan);
 
                if (max_forwards <= 0) {
@@ -318,8 +320,8 @@ static int begin_dial_prerun(struct ast_dial_channel *channel, struct ast_channe
 
        if (cap && ast_format_cap_count(cap)) {
                cap_request = cap;
-       } else if (chan) {
-               cap_request = ast_channel_nativeformats(chan);
+       } else if (requester_cap) {
+               cap_request = requester_cap;
        } else {
                cap_all_audio = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
                ast_format_cap_append_by_type(cap_all_audio, AST_MEDIA_TYPE_AUDIO);
@@ -332,6 +334,7 @@ static int begin_dial_prerun(struct ast_dial_channel *channel, struct ast_channe
                return -1;
        }
        cap_request = NULL;
+       ao2_cleanup(requester_cap);
        ao2_cleanup(cap_all_audio);
 
        if (chan) {
index f44ce42..931bbb9 100644 (file)
@@ -247,7 +247,7 @@ 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 } } ",
+       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,
index b6f88d2..eef1d43 100644 (file)
@@ -59,17 +59,20 @@ static int destroy_contact(void *obj, void *arg, int flags)
 
 static void aor_deleted_observer(const void *object)
 {
+       const struct ast_sip_aor *aor = object;
        const char *aor_id = ast_sorcery_object_get_id(object);
        /* Give enough space for ^ at the beginning and ;@ at the end, since that is our object naming scheme */
        char regex[strlen(aor_id) + 4];
        struct ao2_container *contacts;
 
-       snprintf(regex, sizeof(regex), "^%s;@", aor_id);
+       if (aor->permanent_contacts) {
+               ao2_callback(aor->permanent_contacts, OBJ_NODATA | OBJ_MULTIPLE | OBJ_UNLINK, destroy_contact, NULL);
+       }
 
+       snprintf(regex, sizeof(regex), "^%s;@", aor_id);
        if (!(contacts = ast_sorcery_retrieve_by_regex(ast_sip_get_sorcery(), "contact", regex))) {
                return;
        }
-
        /* Destroy any contacts that may still exist that were made for this AoR */
        ao2_callback(contacts, OBJ_NODATA | OBJ_MULTIPLE | OBJ_UNLINK, destroy_contact, NULL);
 
@@ -302,6 +305,14 @@ int ast_sip_location_update_contact(struct ast_sip_contact *contact)
 
 int ast_sip_location_delete_contact(struct ast_sip_contact *contact)
 {
+       void *contact_status_obj;
+
+       contact_status_obj = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), CONTACT_STATUS, ast_sorcery_object_get_id(contact));
+       if (contact_status_obj) {
+               ast_sorcery_delete(ast_sip_get_sorcery(), contact_status_obj);
+               ao2_ref(contact_status_obj, -1);
+       }
+
        return ast_sorcery_delete(ast_sip_get_sorcery(), contact);
 }
 
index aa753f4..3a6f9d7 100644 (file)
@@ -253,6 +253,17 @@ static const struct ast_sorcery_observer state_contact_status_observer = {
        .updated = persistent_endpoint_contact_status_observer,
 };
 
+static void endpoint_deleted_observer(const void *object)
+{
+       const struct ast_sip_endpoint *endpoint = object;
+
+       ao2_find(persistent_endpoints, ast_endpoint_get_resource(endpoint->persistent), OBJ_SEARCH_KEY | OBJ_UNLINK | OBJ_NODATA);
+}
+
+static const struct ast_sorcery_observer endpoint_observers = {
+       .deleted = endpoint_deleted_observer,
+};
+
 static int dtmf_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
 {
        struct ast_sip_endpoint *endpoint = obj;
@@ -1955,6 +1966,7 @@ int ast_res_pjsip_initialize_configuration(void)
                return -1;
        }
 
+       ast_sorcery_observer_add(sip_sorcery, "endpoint", &endpoint_observers);
        ast_sorcery_observer_add(sip_sorcery, "contact", &state_contact_observer);
        ast_sorcery_observer_add(sip_sorcery, CONTACT_STATUS, &state_contact_status_observer);