diff options
-rw-r--r-- | autoconf/libcurl.m4 | 49 | ||||
-rw-r--r-- | channels/chan_sip.c | 3 | ||||
-rwxr-xr-x | configure | 21 | ||||
-rw-r--r-- | funcs/func_odbc.c | 16 | ||||
-rw-r--r-- | include/asterisk/autoconfig.h.in | 12 | ||||
-rw-r--r-- | include/asterisk/res_odbc.h | 5 | ||||
-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-- | res/res_odbc.c | 16 | ||||
-rw-r--r-- | res/res_pjsip/config_transport.c | 3 | ||||
-rw-r--r-- | res/res_pjsip_t38.c | 4 |
13 files changed, 119 insertions, 20 deletions
diff --git a/autoconf/libcurl.m4 b/autoconf/libcurl.m4 index 085ee0ea0..9a31bfc8b 100644 --- a/autoconf/libcurl.m4 +++ b/autoconf/libcurl.m4 @@ -1,3 +1,24 @@ +#*************************************************************************** +# _ _ ____ _ +# Project ___| | | | _ \| | +# / __| | | | |_) | | +# | (__| |_| | _ <| |___ +# \___|\___/|_| \_\_____| +# +# Copyright (C) 2006, David Shaw <dshaw@jabberwocky.com> +# +# This software is licensed as described in the file COPYING, which +# you should have received as part of this distribution. The terms +# are also available at https://curl.haxx.se/docs/copyright.html. +# +# You may opt to use, copy, modify, merge, publish, distribute and/or sell +# copies of the Software, and permit persons to whom the Software is +# furnished to do so, under the terms of the COPYING file. +# +# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY +# KIND, either express or implied. +# +########################################################################### # LIBCURL_CHECK_CONFIG ([DEFAULT-ACTION], [MINIMUM-VERSION], # [ACTION-IF-YES], [ACTION-IF-NO]) # ---------------------------------------------------------- @@ -55,10 +76,14 @@ AC_DEFUN([AST_LIBCURL_CHECK_CONFIG], AH_TEMPLATE([LIBCURL_PROTOCOL_LDAP],[Defined if libcurl supports LDAP]) AH_TEMPLATE([LIBCURL_PROTOCOL_DICT],[Defined if libcurl supports DICT]) AH_TEMPLATE([LIBCURL_PROTOCOL_TFTP],[Defined if libcurl supports TFTP]) + AH_TEMPLATE([LIBCURL_PROTOCOL_RTSP],[Defined if libcurl supports RTSP]) + AH_TEMPLATE([LIBCURL_PROTOCOL_POP3],[Defined if libcurl supports POP3]) + AH_TEMPLATE([LIBCURL_PROTOCOL_IMAP],[Defined if libcurl supports IMAP]) + AH_TEMPLATE([LIBCURL_PROTOCOL_SMTP],[Defined if libcurl supports SMTP]) AC_SUBST(PBX_CURL) AC_ARG_WITH(libcurl, - AC_HELP_STRING([--with-libcurl=DIR],[look for the curl library in DIR]), + AS_HELP_STRING([--with-libcurl=PREFIX],[look for the curl library in PREFIX/lib and headers in PREFIX/include]), [_libcurl_with=$withval],[_libcurl_with=ifelse([$1],,[yes],[$1])]) if test "$_libcurl_with" != "no" ; then @@ -72,10 +97,10 @@ AC_DEFUN([AST_LIBCURL_CHECK_CONFIG], if test -d "$_libcurl_with" ; then CURL_INCLUDE="-I$withval/include" _libcurl_ldflags="-L$withval/lib" - AC_PATH_PROG([_libcurl_config],[curl-config],["$withval/bin"], + AC_PATH_PROG([_libcurl_config],[curl-config],[], ["$withval/bin"]) else - AC_PATH_PROG([_libcurl_config],[curl-config]) + AC_PATH_PROG([_libcurl_config],[curl-config],[],[$PATH]) fi if test x$_libcurl_config != "x" ; then @@ -143,18 +168,19 @@ AC_DEFUN([AST_LIBCURL_CHECK_CONFIG], _libcurl_save_libs=$LIBS LIBS="$CURL_LIB $LIBS" - AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <curl/curl.h>],[ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <curl/curl.h>]],[[ /* Try and use a few common options to force a failure if we are missing symbols or can't link. */ int x; curl_easy_setopt(NULL,CURLOPT_URL,NULL); x=CURL_ERROR_SIZE; x=CURLOPT_WRITEFUNCTION; -x=CURLOPT_FILE; +x=CURLOPT_WRITEDATA; x=CURLOPT_ERRORBUFFER; x=CURLOPT_STDERR; x=CURLOPT_VERBOSE; -])],libcurl_cv_lib_curl_usable=yes,libcurl_cv_lib_curl_usable=no) +if (x) {;} +]])],libcurl_cv_lib_curl_usable=yes,libcurl_cv_lib_curl_usable=no) CPPFLAGS=$_libcurl_save_cppflags LIBS=$_libcurl_save_libs @@ -196,17 +222,23 @@ x=CURLOPT_VERBOSE; # We don't have --protocols, so just assume that all # protocols are available - _libcurl_protocols="HTTP FTP FILE TELNET LDAP DICT" + _libcurl_protocols="HTTP FTP FILE TELNET LDAP DICT TFTP" if test x$libcurl_feature_SSL = xyes ; then _libcurl_protocols="$_libcurl_protocols HTTPS" # FTPS wasn't standards-compliant until version - # 7.11.0 + # 7.11.0 (0x070b00 == 461568) if test $_libcurl_version -ge 461568; then _libcurl_protocols="$_libcurl_protocols FTPS" fi fi + + # RTSP, IMAP, POP3 and SMTP were added in + # 7.20.0 (0x071400 == 463872) + if test $_libcurl_version -ge 463872; then + _libcurl_protocols="$_libcurl_protocols RTSP IMAP POP3 SMTP" + fi fi for _libcurl_protocol in $_libcurl_protocols ; do @@ -241,4 +273,3 @@ x=CURLOPT_VERBOSE; unset _libcurl_with ])dnl - diff --git a/channels/chan_sip.c b/channels/chan_sip.c index a5aa6c3d3..7d4cf8722 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -7665,7 +7665,8 @@ static int interpret_t38_parameters(struct sip_pvt *p, const struct ast_control_ ast_udptl_set_local_max_ifp(p->udptl, p->t38.our_parms.max_ifp); change_t38_state(p, T38_ENABLED); transmit_response_with_t38_sdp(p, "200 OK", &p->initreq, XMIT_CRITICAL); - } else if (p->t38.state != T38_ENABLED) { + } else if ((p->t38.state != T38_ENABLED) || ((p->t38.state == T38_ENABLED) && + (parameters->request_response == AST_T38_REQUEST_NEGOTIATE))) { p->t38.our_parms = *parameters; ast_udptl_set_local_max_ifp(p->udptl, p->t38.our_parms.max_ifp); change_t38_state(p, T38_LOCAL_REINVITE); @@ -2086,7 +2086,8 @@ Optional Packages: --with-uriparser=PATH use uriparser library files in PATH --with-kqueue=PATH use kqueue support files in PATH --with-ldap=PATH use OpenLDAP files in PATH - --with-libcurl=DIR look for the curl library in DIR + --with-libcurl=PREFIX look for the curl library in PREFIX/lib and headers + in PREFIX/include --with-libedit=PATH use NetBSD Editline library files in PATH, use 'internal' Editline otherwise --with-libxml2=PATH use LibXML2 files in PATH @@ -9451,6 +9452,10 @@ fi + + + + # Check whether --with-libcurl was given. if test "${with_libcurl+set}" = set; then : withval=$with_libcurl; _libcurl_with=$withval @@ -9538,7 +9543,6 @@ done done IFS=$as_save_IFS - test -z "$ac_cv_path__libcurl_config" && ac_cv_path__libcurl_config=""$withval/bin"" ;; esac fi @@ -9688,10 +9692,11 @@ int x; curl_easy_setopt(NULL,CURLOPT_URL,NULL); x=CURL_ERROR_SIZE; x=CURLOPT_WRITEFUNCTION; -x=CURLOPT_FILE; +x=CURLOPT_WRITEDATA; x=CURLOPT_ERRORBUFFER; x=CURLOPT_STDERR; x=CURLOPT_VERBOSE; +if (x) {;} ; return 0; @@ -9758,17 +9763,23 @@ _ACEOF # We don't have --protocols, so just assume that all # protocols are available - _libcurl_protocols="HTTP FTP FILE TELNET LDAP DICT" + _libcurl_protocols="HTTP FTP FILE TELNET LDAP DICT TFTP" if test x$libcurl_feature_SSL = xyes ; then _libcurl_protocols="$_libcurl_protocols HTTPS" # FTPS wasn't standards-compliant until version - # 7.11.0 + # 7.11.0 (0x070b00 == 461568) if test $_libcurl_version -ge 461568; then _libcurl_protocols="$_libcurl_protocols FTPS" fi fi + + # RTSP, IMAP, POP3 and SMTP were added in + # 7.20.0 (0x071400 == 463872) + if test $_libcurl_version -ge 463872; then + _libcurl_protocols="$_libcurl_protocols RTSP IMAP POP3 SMTP" + fi fi for _libcurl_protocol in $_libcurl_protocols ; do diff --git a/funcs/func_odbc.c b/funcs/func_odbc.c index b067f968a..e2ca7c823 100644 --- a/funcs/func_odbc.c +++ b/funcs/func_odbc.c @@ -388,9 +388,25 @@ static struct odbc_obj *get_odbc_obj(const char *dsn_name, struct dsn **dsn) static inline void release_obj_or_dsn(struct odbc_obj **obj, struct dsn **dsn) { if (dsn && *dsn) { + /* If multiple connections are not enabled then the guarantee + * of a single connection already exists and holding on to the + * connection would prevent any other user from acquiring it + * indefinitely. + */ + if (ast_odbc_get_max_connections((*dsn)->name) < 2) { + ast_odbc_release_obj((*dsn)->connection); + (*dsn)->connection = NULL; + } ao2_unlock(*dsn); ao2_ref(*dsn, -1); *dsn = NULL; + /* Some callers may provide both an obj and dsn. To ensure that + * the connection is not released twice we set it to NULL here if + * present. + */ + if (obj) { + *obj = NULL; + } } else if (obj && *obj) { ast_odbc_release_obj(*obj); *obj = NULL; diff --git a/include/asterisk/autoconfig.h.in b/include/asterisk/autoconfig.h.in index 64580205c..8f02ee572 100644 --- a/include/asterisk/autoconfig.h.in +++ b/include/asterisk/autoconfig.h.in @@ -1211,9 +1211,21 @@ /* Defined if libcurl supports HTTPS */ #undef LIBCURL_PROTOCOL_HTTPS +/* Defined if libcurl supports IMAP */ +#undef LIBCURL_PROTOCOL_IMAP + /* Defined if libcurl supports LDAP */ #undef LIBCURL_PROTOCOL_LDAP +/* Defined if libcurl supports POP3 */ +#undef LIBCURL_PROTOCOL_POP3 + +/* Defined if libcurl supports RTSP */ +#undef LIBCURL_PROTOCOL_RTSP + +/* Defined if libcurl supports SMTP */ +#undef LIBCURL_PROTOCOL_SMTP + /* Defined if libcurl supports TELNET */ #undef LIBCURL_PROTOCOL_TELNET diff --git a/include/asterisk/res_odbc.h b/include/asterisk/res_odbc.h index 8c7b54950..137f7d4a5 100644 --- a/include/asterisk/res_odbc.h +++ b/include/asterisk/res_odbc.h @@ -243,4 +243,9 @@ int ast_odbc_text2isolation(const char *txt); */ const char *ast_odbc_isolation2text(int iso); +/*! + * \brief Return the current configured maximum number of connections for a class + */ +unsigned int ast_odbc_get_max_connections(const char *name); + #endif /* _ASTERISK_RES_ODBC_H */ 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/res/res_odbc.c b/res/res_odbc.c index b2204ff09..31ea29b03 100644 --- a/res/res_odbc.c +++ b/res/res_odbc.c @@ -744,6 +744,22 @@ static int aoro2_class_cb(void *obj, void *arg, int flags) return 0; } +unsigned int ast_odbc_get_max_connections(const char *name) +{ + struct odbc_class *class; + unsigned int max_connections; + + class = ao2_callback(class_container, 0, aoro2_class_cb, (char *) name); + if (!class) { + return 0; + } + + max_connections = class->maxconnections; + ao2_ref(class, -1); + + return max_connections; +} + /* * \brief Determine if the connection has died. * diff --git a/res/res_pjsip/config_transport.c b/res/res_pjsip/config_transport.c index b9208976f..60b4507cd 100644 --- a/res/res_pjsip/config_transport.c +++ b/res/res_pjsip/config_transport.c @@ -562,12 +562,13 @@ static int transport_apply(const struct ast_sorcery *sorcery, void *obj) } } else if (transport->type == AST_TRANSPORT_TCP) { pjsip_tcp_transport_cfg cfg; - int option = 1; + static int option = 1; pjsip_tcp_transport_cfg_default(&cfg, temp_state->state->host.addr.sa_family); cfg.bind_addr = temp_state->state->host; cfg.async_cnt = transport->async_operations; set_qos(transport, &cfg.qos_params); + /* sockopt_params.options is copied to each newly connected socket */ cfg.sockopt_params.options[0].level = pj_SOL_TCP(); cfg.sockopt_params.options[0].optname = pj_TCP_NODELAY(); cfg.sockopt_params.options[0].optval = &option; diff --git a/res/res_pjsip_t38.c b/res/res_pjsip_t38.c index 14207d9c0..992902af2 100644 --- a/res/res_pjsip_t38.c +++ b/res/res_pjsip_t38.c @@ -361,7 +361,9 @@ static int t38_interpret_parameters(void *obj) ast_udptl_set_local_max_ifp(session_media->udptl, state->our_parms.max_ifp); t38_change_state(data->session, session_media, state, T38_ENABLED); ast_sip_session_resume_reinvite(data->session); - } else if (data->session->t38state != T38_ENABLED) { + } else if ((data->session->t38state != T38_ENABLED) || + ((data->session->t38state == T38_ENABLED) && + (parameters->request_response == AST_T38_REQUEST_NEGOTIATE))) { if (t38_initialize_session(data->session, session_media)) { break; } |