Merge "res_pjsip: Make aor named lock a mutex."
authorzuul <zuul@gerrit.asterisk.org>
Fri, 12 Aug 2016 04:27:15 +0000 (23:27 -0500)
committerGerrit Code Review <gerrit2@gerrit.digium.api>
Fri, 12 Aug 2016 04:27:15 +0000 (23:27 -0500)
CHANGES
cdr/cdr_adaptive_odbc.c
configs/samples/extensions.conf.sample
configure
configure.ac
include/asterisk/autoconfig.h.in
main/Makefile
res/res_odbc.c
res/res_resolver_unbound.c

diff --git a/CHANGES b/CHANGES
index ee74625..7f3b0ad 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -286,12 +286,11 @@ Core
    - 'media cache delete <item>' - remove an item from the cache
    - 'media cache create <uri>' - retrieve a URI and store it in the cache
 
- * The ability for hints to be automatically created as a result of device state
-   changes now exists in the PBX. This functionality is referred to as "autohints"
-   and is configurable in extensions.conf by placing "autohints=yes" in the
-   context. If enabled then a hint will be automatically created with the name of
-   the device.
-
+ * The ability for device state hints to be automatically created as a result of
+   device state changes now exists in the PBX. This functionality is referred to
+   as "autohints" and is configurable in extensions.conf by placing "autohints=yes"
+   in the context. If enabled a device state hint will be automatically created
+   with the name of the device.
 
 Functions
 ------------------
index 0da8c01..f0bcc09 100644 (file)
@@ -408,6 +408,7 @@ static int odbc_log(struct ast_cdr *cdr)
        AST_LIST_TRAVERSE(&odbc_tables, tableptr, list) {
                separator = "";
 
+               quoted = 0;
                if (tableptr->quoted_identifiers != '\0'){
                        quoted = 1;
                }
index f8770c5..28319b5 100644 (file)
@@ -197,6 +197,11 @@ TRUNKMSD=1                                 ; MSD digits to strip (usually 1 or 0)
 ; before "B".
 ;
 ;[context]
+;
+;autohints = yes
+; If enabled for a context, a device state hint will be automatically created in
+; the context with the name of the device and updated with device state changes.
+;
 ;exten => someexten,{priority|label{+|-}offset}[(alias)],application(arg1,arg2,...)
 ;
 ; Timing list for includes is
index 8bce35d..5ac2a14 100755 (executable)
--- a/configure
+++ b/configure
@@ -23683,7 +23683,7 @@ if test "x${PBX_UNBOUND}" != "x1" -a "${USE_UNBOUND}" != "no"; then
          pbxlibdir="-L${UNBOUND_DIR}"
       fi
    fi
-   pbxfuncname="ub_ctx_add_ta_autr"
+   pbxfuncname="ub_ctx_delete"
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_UNBOUND_FOUND=yes
    else
 
 
 
+    if test "x${PBX_UNBOUND_CONST_PARAMS}" != "x1" -a "${USE_UNBOUND_CONST_PARAMS}" != "no"; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for UNBOUND_VERSION_MAJOR declared in unbound.h" >&5
+$as_echo_n "checking for UNBOUND_VERSION_MAJOR declared in unbound.h... " >&6; }
+        saved_cppflags="${CPPFLAGS}"
+        if test "x${UNBOUND_CONST_PARAMS_DIR}" != "x"; then
+            UNBOUND_CONST_PARAMS_INCLUDE="-I${UNBOUND_CONST_PARAMS_DIR}/include"
+        fi
+        CPPFLAGS="${CPPFLAGS} ${UNBOUND_CONST_PARAMS_INCLUDE}"
+
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+ #include <unbound.h>
+int
+main ()
+{
+#if !defined(UNBOUND_VERSION_MAJOR)
+                                    (void) UNBOUND_VERSION_MAJOR;
+                                #endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+     { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+                PBX_UNBOUND_CONST_PARAMS=1
+
+$as_echo "#define HAVE_UNBOUND_CONST_PARAMS 1" >>confdefs.h
+
+
+
+else
+     { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+        CPPFLAGS="${saved_cppflags}"
+    fi
+
+
 
 if test "x${PBX_UNIXODBC}" != "x1" -a "${USE_UNIXODBC}" != "no"; then
    pbxlibdir=""
index ed6f8a8..8ea1cb0 100644 (file)
@@ -2101,7 +2101,8 @@ AST_EXT_LIB_CHECK([NEWT], [newt], [newtBell], [newt.h])
 # script bug which does not find the ldns library.  The bug is fixed in
 # v1.4.22 but that version is not easily detectable.
 #
-AST_EXT_LIB_CHECK([UNBOUND], [unbound], [ub_ctx_add_ta_autr], [unbound.h], [])
+AST_EXT_LIB_CHECK([UNBOUND], [unbound], [ub_ctx_delete], [unbound.h], [])
+AST_C_DECLARE_CHECK([UNBOUND_CONST_PARAMS], [UNBOUND_VERSION_MAJOR], [unbound.h])
 
 AST_EXT_LIB_CHECK([UNIXODBC], [odbc], [SQLConnect], [sql.h], [])
 
index b48257e..bdd93bb 100644 (file)
 /* Define to 1 if you have the unbound library. */
 #undef HAVE_UNBOUND
 
+/* Define if your system has UNBOUND_VERSION_MAJOR declared. */
+#undef HAVE_UNBOUND_CONST_PARAMS
+
 /* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
 
index 663508a..a6c3ab1 100644 (file)
@@ -233,7 +233,7 @@ ASTSSL_LIB:=libasteriskssl.dylib
 # -install_name allows library to be found if installed somewhere other than
 # /lib or /usr/lib
 $(ASTSSL_LIB): _ASTLDFLAGS+=-dynamiclib -install_name $(ASTLIBDIR)/$(ASTSSL_LIB)
-$(ASTSSL_LIB): _ASTCFLAGS+=-fPIC -DAST_MODULE=\"asteriskssl\"
+$(ASTSSL_LIB): _ASTCFLAGS+=-fPIC -DAST_MODULE=\"asteriskssl\" -DAST_NOT_MODULE
 $(ASTSSL_LIB): LIBS+=$(ASTSSL_LIBS)
 $(ASTSSL_LIB): SOLINK=$(DYLINK)
 
@@ -309,7 +309,7 @@ ASTPJ_LIB:=libasteriskpj.dylib
 # -install_name allows library to be found if installed somewhere other than
 # /lib or /usr/lib
 $(ASTPJ_LIB): _ASTLDFLAGS+=-dynamiclib -install_name $(ASTLIBDIR)/$(ASTPJ_LIB) $(PJ_LDFLAGS)
-$(ASTPJ_LIB): _ASTCFLAGS+=-fPIC -DAST_MODULE=\"asteriskpj\" $(PJ_CFLAGS)
+$(ASTPJ_LIB): _ASTCFLAGS+=-fPIC -DAST_MODULE=\"asteriskpj\" $(PJ_CFLAGS) -DAST_NOT_MODULE
 $(ASTPJ_LIB): LIBS+=$(PJPROJECT_LIBS)  -lssl -lcrypto -luuid -lm -lrt -lpthread
 $(ASTPJ_LIB): SOLINK=$(DYLINK)
 
index bd64b9f..62faf98 100644 (file)
@@ -668,10 +668,14 @@ static char *handle_cli_odbc_show(struct ast_cli_entry *e, int cmd, struct ast_c
                        char timestr[80];
                        struct ast_tm tm;
 
-                       ast_localtime(&class->last_negative_connect, &tm, NULL);
-                       ast_strftime(timestr, sizeof(timestr), "%Y-%m-%d %T", &tm);
                        ast_cli(a->fd, "  Name:   %s\n  DSN:    %s\n", class->name, class->dsn);
-                       ast_cli(a->fd, "    Last connection attempt: %s\n", timestr);
+
+                       if (class->last_negative_connect.tv_sec > 0) {
+                               ast_localtime(&class->last_negative_connect, &tm, NULL);
+                               ast_strftime(timestr, sizeof(timestr), "%Y-%m-%d %T", &tm);
+                               ast_cli(a->fd, "    Last fail connection attempt: %s\n", timestr);
+                       }
+
                        ast_cli(a->fd, "    Number of active connections: %zd (out of %d)\n", class->connection_cnt, class->maxconnections);
                        ast_cli(a->fd, "\n");
                }
index 3eeb651..40f3cfe 100644 (file)
@@ -79,6 +79,17 @@ ASTERISK_REGISTER_FILE()
        </configInfo>
  ***/
 
+/*!
+ * Unbound versions <= 1.4.20 declare string function parameters as 'char *'
+ * but versions >= 1.4.21 declare them as 'const char *'.  Since CentOS6 is still
+ * at 1.4.20, we need to cast away the 'const' if we detect the earlier version.
+ */
+#ifdef HAVE_UNBOUND_CONST_PARAMS
+#define UNBOUND_CHAR const char
+#else
+#define UNBOUND_CHAR char
+#endif
+
 /*! \brief Structure for an unbound resolver */
 struct unbound_resolver {
        /*! \brief Resolver context itself */
@@ -292,7 +303,7 @@ static int unbound_resolver_resolve(struct ast_dns_query *query)
        data->resolver = ao2_bump(cfg->global->state->resolver);
        ast_dns_resolver_set_data(query, data);
 
-       res = ub_resolve_async(data->resolver->context, ast_dns_query_get_name(query),
+       res = ub_resolve_async(data->resolver->context, (UNBOUND_CHAR *)ast_dns_query_get_name(query),
                ast_dns_query_get_rr_type(query), ast_dns_query_get_rr_class(query),
                ao2_bump(query), unbound_resolver_callback, &data->id);
 
@@ -404,7 +415,7 @@ static int unbound_config_preapply(struct unbound_config *cfg)
        if (!strcmp(cfg->global->hosts, "system")) {
                res = ub_ctx_hosts(cfg->global->state->resolver->context, NULL);
        } else if (!ast_strlen_zero(cfg->global->hosts)) {
-               res = ub_ctx_hosts(cfg->global->state->resolver->context, cfg->global->hosts);
+               res = ub_ctx_hosts(cfg->global->state->resolver->context, (UNBOUND_CHAR *)cfg->global->hosts);
        }
 
        if (res) {
@@ -419,7 +430,7 @@ static int unbound_config_preapply(struct unbound_config *cfg)
 
                it_nameservers = ao2_iterator_init(cfg->global->nameservers, 0);
                while ((nameserver = ao2_iterator_next(&it_nameservers))) {
-                       res = ub_ctx_set_fwd(cfg->global->state->resolver->context, nameserver);
+                       res = ub_ctx_set_fwd(cfg->global->state->resolver->context, (UNBOUND_CHAR *)nameserver);
 
                        if (res) {
                                ast_log(LOG_ERROR, "Failed to add nameserver '%s' to unbound resolver: %s\n",
@@ -434,7 +445,7 @@ static int unbound_config_preapply(struct unbound_config *cfg)
        if (!strcmp(cfg->global->resolv, "system")) {
                res = ub_ctx_resolvconf(cfg->global->state->resolver->context, NULL);
        } else if (!ast_strlen_zero(cfg->global->resolv)) {
-               res = ub_ctx_resolvconf(cfg->global->state->resolver->context, cfg->global->resolv);
+               res = ub_ctx_resolvconf(cfg->global->state->resolver->context, (UNBOUND_CHAR *)cfg->global->resolv);
        }
 
        if (res) {
@@ -444,7 +455,7 @@ static int unbound_config_preapply(struct unbound_config *cfg)
        }
 
        if (!ast_strlen_zero(cfg->global->ta_file)) {
-               res = ub_ctx_add_ta_file(cfg->global->state->resolver->context, cfg->global->ta_file);
+               res = ub_ctx_add_ta_file(cfg->global->state->resolver->context, (UNBOUND_CHAR *)cfg->global->ta_file);
 
                if (res) {
                        ast_log(LOG_ERROR, "Failed to set trusted anchor file to '%s' in unbound resolver: %s\n",
@@ -740,13 +751,13 @@ static enum ast_test_result_state nominal_test(struct ast_test *test, resolve_fn
        static const size_t V4_SIZE = sizeof(struct in_addr);
        static const size_t V6_SIZE = sizeof(struct in6_addr);
 
-       static const char *DOMAIN1 = "goose.feathers";
-       static const char *DOMAIN2 = "duck.feathers";
+       static UNBOUND_CHAR *DOMAIN1 = "goose.feathers";
+       static UNBOUND_CHAR *DOMAIN2 = "duck.feathers";
 
-       static const char *ADDR1 = "127.0.0.2";
-       static const char *ADDR2 = "127.0.0.3";
-       static const char *ADDR3 = "::1";
-       static const char *ADDR4 = "127.0.0.4";
+       static UNBOUND_CHAR *ADDR1 = "127.0.0.2";
+       static UNBOUND_CHAR *ADDR2 = "127.0.0.3";
+       static UNBOUND_CHAR *ADDR3 = "::1";
+       static UNBOUND_CHAR *ADDR4 = "127.0.0.4";
 
        char addr1_buf[V4_SIZE];
        char addr2_buf[V4_SIZE];
@@ -786,7 +797,7 @@ static enum ast_test_result_state nominal_test(struct ast_test *test, resolve_fn
        ub_ctx_zone_add(resolver->context, DOMAIN2, "static");
 
        for (i = 0; i < ARRAY_LEN(records); ++i) {
-               ub_ctx_data_add(resolver->context, records[i].as_string);
+               ub_ctx_data_add(resolver->context, (UNBOUND_CHAR *)records[i].as_string);
        }
 
        for (i = 0; i < ARRAY_LEN(runs); ++i) {
@@ -808,7 +819,7 @@ static enum ast_test_result_state nominal_test(struct ast_test *test, resolve_fn
 
 cleanup:
        for (i = 0; i < ARRAY_LEN(records); ++i) {
-               ub_ctx_data_remove(resolver->context, records[i].as_string);
+               ub_ctx_data_remove(resolver->context, (UNBOUND_CHAR *)records[i].as_string);
        }
        ub_ctx_zone_remove(resolver->context, DOMAIN1);
        ub_ctx_zone_remove(resolver->context, DOMAIN2);
@@ -1012,10 +1023,10 @@ static enum ast_test_result_state off_nominal_test(struct ast_test *test,
 
        static const size_t V4_SIZE = sizeof(struct in_addr);
 
-       static const char *DOMAIN1 = "goose.feathers";
-       static const char *DOMAIN2 = "duck.feathers";
+       static UNBOUND_CHAR *DOMAIN1 = "goose.feathers";
+       static UNBOUND_CHAR *DOMAIN2 = "duck.feathers";
 
-       static const char *ADDR1 = "127.0.0.2";
+       static UNBOUND_CHAR *ADDR1 = "127.0.0.2";
 
        char addr1_buf[V4_SIZE];
 
@@ -1046,7 +1057,7 @@ static enum ast_test_result_state off_nominal_test(struct ast_test *test,
        ub_ctx_zone_add(resolver->context, DOMAIN2, "static");
 
        for (i = 0; i < ARRAY_LEN(records); ++i) {
-               ub_ctx_data_add(resolver->context, records[i].as_string);
+               ub_ctx_data_add(resolver->context, (UNBOUND_CHAR *)records[i].as_string);
        }
 
        for (i = 0; i < ARRAY_LEN(runs); ++i) {
@@ -1196,7 +1207,7 @@ AST_TEST_DEFINE(resolve_naptr)
 
        const struct ast_dns_record *record;
 
-       static const char * DOMAIN1 = "goose.feathers";
+       static char * DOMAIN1 = "goose.feathers";
        int i;
        enum ast_test_result_state res = AST_TEST_PASS;
 
@@ -1234,7 +1245,7 @@ AST_TEST_DEFINE(resolve_naptr)
        ub_ctx_zone_add(resolver->context, DOMAIN1, "static");
 
        for (i = 0; i < ARRAY_LEN(records); ++i) {
-               ub_ctx_data_add(resolver->context, records[i].zone_entry);
+               ub_ctx_data_add(resolver->context, (UNBOUND_CHAR *)records[i].zone_entry);
        }
 
        if (ast_dns_resolve(DOMAIN1, ns_t_naptr, ns_c_in, &result)) {
@@ -1311,8 +1322,8 @@ AST_TEST_DEFINE(resolve_srv)
        RAII_VAR(struct unbound_config *, cfg, NULL, ao2_cleanup);
        RAII_VAR(struct ast_dns_result *, result, NULL, ast_dns_result_free);
        const struct ast_dns_record *record;
-       static const char *DOMAIN1 = "taco.bananas";
-       static const char *DOMAIN1_SRV = "taco.bananas 12345 IN SRV 10 20 5060 sip.taco.bananas";
+       static UNBOUND_CHAR *DOMAIN1 = "taco.bananas";
+       static UNBOUND_CHAR *DOMAIN1_SRV = "taco.bananas 12345 IN SRV 10 20 5060 sip.taco.bananas";
        enum ast_test_result_state res = AST_TEST_PASS;
 
        switch (cmd) {