Merge "vector: Additional enhancements and fixes"
authorMatt Jordan <mjordan@digium.com>
Thu, 7 May 2015 18:30:17 +0000 (13:30 -0500)
committerGerrit Code Review <gerrit2@gerrit.digium.api>
Thu, 7 May 2015 18:30:17 +0000 (13:30 -0500)
47 files changed:
Makefile.moddir_rules
cdr/cdr_csv.c
channels/chan_dahdi.c
channels/dahdi/bridge_native_dahdi.c
channels/dahdi/bridge_native_dahdi.h
channels/sip/dialplan_functions.c
codecs/lpc10/lpcini.c
configs/samples/chan_dahdi.conf.sample
include/asterisk.h
include/asterisk/app.h
include/asterisk/bridge_technology.h
include/asterisk/bucket.h
include/asterisk/cli.h
include/asterisk/codec.h
include/asterisk/data.h
include/asterisk/format.h
include/asterisk/manager.h
include/asterisk/mod_format.h
include/asterisk/module.h
include/asterisk/parking.h
include/asterisk/pbx.h
include/asterisk/rtp_engine.h
include/asterisk/sorcery.h
include/asterisk/timing.h
include/asterisk/translate.h
main/Makefile
main/bridge_basic.c
main/cli.c
main/libasteriskssl.c
main/parking.c
main/tcptls.c
res/parking/parking_applications.c
res/parking/parking_bridge_features.c
res/parking/parking_manager.c
res/parking/res_parking.h
res/res_clioriginate.c
res/res_convert.c
res/res_parking.c
res/res_pjsip.c
res/res_pjsip/include/res_pjsip_private.h
res/res_pjsip/pjsip_configuration.c
res/res_pjsip/pjsip_options.c
res/res_stasis_snoop.c
utils/Makefile
utils/ael_main.c
utils/clicompat.c
utils/conf2ael.c

index d2964e3..e702282 100644 (file)
@@ -60,7 +60,11 @@ endif
 # is used to collect the required flags for a module... which can
 # then be used any place they are required.
 
-MOD_ASTCFLAGS=-DAST_MODULE=\"$(1)\" $(MENUSELECT_OPTS_$(1):%=-D%) $(foreach dep,$(MENUSELECT_DEPENDS_$(1)),$(value $(dep)_INCLUDE))
+MOD_ASTCFLAGS=\
+       -DAST_MODULE=\"$(1)\" \
+       -DAST_MODULE_SELF_SYM=__internal_$(1)_self \
+       $(MENUSELECT_OPTS_$(1):%=-D%) \
+       $(foreach dep,$(MENUSELECT_DEPENDS_$(1)),$(value $(dep)_INCLUDE))
 
 define MOD_ADD_SOURCE
 $$(if $$(filter $(1),$$(EMBEDDED_MODS)),modules.link,$(1).so): $$(subst $(3),$(5),$(2))
index a480a47..6fb2b71 100644 (file)
@@ -94,8 +94,7 @@ static const char config[] = "cdr.conf";
 
 static char *name = "csv";
 
-AST_MUTEX_DEFINE_STATIC(mf_lock);
-AST_MUTEX_DEFINE_STATIC(acf_lock);
+AST_MUTEX_DEFINE_STATIC(f_lock);
 
 static int load_config(int reload)
 {
@@ -261,36 +260,37 @@ static int build_csv_record(char *buf, size_t bufsize, struct ast_cdr *cdr)
        return -1;
 }
 
-static int writefile(char *s, char *acc)
+static int writefile(char *s, char *file_path)
 {
-       char tmp[PATH_MAX];
        FILE *f;
-
-       if (strchr(acc, '/') || (acc[0] == '.')) {
-               ast_log(LOG_WARNING, "Account code '%s' insecure for writing file\n", acc);
-               return -1;
-       }
-
-       snprintf(tmp, sizeof(tmp), "%s/%s/%s.csv", ast_config_AST_LOG_DIR,CSV_LOG_DIR, acc);
-
-       ast_mutex_lock(&acf_lock);
-       if (!(f = fopen(tmp, "a"))) {
-               ast_mutex_unlock(&acf_lock);
-               ast_log(LOG_ERROR, "Unable to open file %s : %s\n", tmp, strerror(errno));
+       /* because of the absolutely unconditional need for the
+          highest reliability possible in writing billing records,
+          we open write and close the log file each time */
+       if (!(f = fopen(file_path, "a"))) {
+               ast_log(LOG_ERROR, "Unable to open file %s : %s\n", file_path, strerror(errno));
                return -1;
        }
        fputs(s, f);
-       fflush(f);
+       fflush(f); /* be particularly anal here */
        fclose(f);
-       ast_mutex_unlock(&acf_lock);
 
        return 0;
 }
 
 
+static int writefile_account(char *s, char *acc)
+{
+       char file_account[PATH_MAX];
+       if (strchr(acc, '/') || (acc[0] == '.')) {
+               ast_log(LOG_WARNING, "Account code '%s' insecure for writing file\n", acc);
+               return -1;
+       }
+       snprintf(file_account, sizeof(file_account), "%s/%s/%s.csv", ast_config_AST_LOG_DIR,CSV_LOG_DIR, acc);
+       return writefile(s, file_account);
+}
+
 static int csv_log(struct ast_cdr *cdr)
 {
-       FILE *mf = NULL;
        /* Make sure we have a big enough buf */
        char buf[1024];
        char csvmaster[PATH_MAX];
@@ -300,26 +300,15 @@ static int csv_log(struct ast_cdr *cdr)
                return 0;
        }
 
-       /* because of the absolutely unconditional need for the
-          highest reliability possible in writing billing records,
-          we open write and close the log file each time */
-       ast_mutex_lock(&mf_lock);
-       if ((mf = fopen(csvmaster, "a"))) {
-               fputs(buf, mf);
-               fflush(mf); /* be particularly anal here */
-               fclose(mf);
-               mf = NULL;
-               ast_mutex_unlock(&mf_lock);
-       } else {
-               ast_mutex_unlock(&mf_lock);
-               ast_log(LOG_ERROR, "Unable to re-open master file %s : %s\n", csvmaster, strerror(errno));
-       }
+       ast_mutex_lock(&f_lock);
+       if (writefile(buf, csvmaster))
+               ast_log(LOG_WARNING, "Unable to write CSV record to master '%s' : %s\n", csvmaster, strerror(errno));
 
        if (accountlogs && !ast_strlen_zero(cdr->accountcode)) {
-               if (writefile(buf, cdr->accountcode))
+               if (writefile_account(buf, cdr->accountcode))
                        ast_log(LOG_WARNING, "Unable to write CSV record to account file '%s' : %s\n", cdr->accountcode, strerror(errno));
        }
-
+       ast_mutex_unlock(&f_lock);
        return 0;
 }
 
index b9405d5..0b187dc 100644 (file)
@@ -19519,7 +19519,7 @@ static int load_module(void)
        ast_format_cap_append(dahdi_tech.capabilities, ast_format_ulaw, 0);
        ast_format_cap_append(dahdi_tech.capabilities, ast_format_alaw, 0);
 
-       if (dahdi_native_load(ast_module_info->self, &dahdi_tech)) {
+       if (dahdi_native_load(&dahdi_tech)) {
                ao2_ref(dahdi_tech.capabilities, -1);
                return AST_MODULE_LOAD_FAILURE;
        }
index d67cb5c..234228b 100644 (file)
@@ -903,11 +903,11 @@ void dahdi_native_unload(void)
  * \retval 0 on success.
  * \retval -1 on error.
  */
-int dahdi_native_load(struct ast_module *mod, const struct ast_channel_tech *tech)
+int dahdi_native_load(const struct ast_channel_tech *tech)
 {
        dahdi_tech = tech;
 
-       if (__ast_bridge_technology_register(&native_bridge, mod)) {
+       if (ast_bridge_technology_register(&native_bridge)) {
                dahdi_native_unload();
                return -1;
        }
index 91e8d16..6362a6f 100644 (file)
@@ -36,7 +36,7 @@ extern "C" {
 /* ------------------------------------------------------------------- */
 
 void dahdi_native_unload(void);
-int dahdi_native_load(struct ast_module *mod, const struct ast_channel_tech *tech);
+int dahdi_native_load(const struct ast_channel_tech *tech);
 
 /* ------------------------------------------------------------------- */
 
index 91a4678..33ba71c 100644 (file)
@@ -338,7 +338,7 @@ AST_TEST_DEFINE(test_sip_rtpqos_1)
                break;
        }
 
-       ast_rtp_engine_register2(&test_engine, NULL);
+       ast_rtp_engine_register(&test_engine);
        /* Have to associate this with a SIP pvt and an ast_channel */
        if (!(p = sip_alloc(0, NULL, 0, SIP_NOTIFY, NULL, 0))) {
                res = AST_TEST_NOT_RUN;
index 42c2331..ebe229a 100644 (file)
@@ -34,7 +34,7 @@ Some OSS fixes and a few lpc changes to make it actually work
        -lf2c -lm   (in that order)
 */
 
-#include "asterisk.h"
+#include <stdlib.h>
 #include "f2c.h"
 
 #ifdef P_R_O_T_O_T_Y_P_E_S
index e67574b..e0c69eb 100644 (file)
@@ -196,10 +196,12 @@ context=public
 ;
 ;resetinterval = 3600
 ;
-; Enable per span to force a RESTART on a channel that returns a cause
-; code of PRI_CAUSE_REQUESTED_CHAN_UNAVAIL(44).  If the cause is because
-; of a stuck channel on the peer and the channel is always the next
-; channel we pick for an outgoing call then this might help.
+; Enable per ISDN span to force a RESTART on a channel that returns a cause
+; code of PRI_CAUSE_REQUESTED_CHAN_UNAVAIL(44).  If this option is enabled
+; and the reason the peer rejected the call with cause 44 was that the
+; channel is stuck in an unavailable state on the peer, then this might
+; help release the channel.  It is worth noting that the next outgoing call
+; Asterisk makes will likely try the same channel again.
 ;
 ; NOTE: Sending a RESTART in response to a cause 44 is not required
 ; (nor prohibited) by the standards and is likely a primitive chan_dahdi
index 14e88e6..ab2a3dd 100644 (file)
@@ -271,4 +271,21 @@ struct ast_sched_context;
 #define __stringify_1(x)       #x
 #define __stringify(x)         __stringify_1(x)
 
+#if defined(AST_IN_CORE) \
+       || (!defined(AST_MODULE_SELF_SYM) \
+               && (defined(STANDALONE) || defined(STANDALONE2) || defined(AST_NOT_MODULE)))
+
+#define AST_MODULE_SELF NULL
+
+#elif defined(AST_MODULE_SELF_SYM)
+
+/*! Retreive the 'struct ast_module *' for the current module. */
+#define AST_MODULE_SELF AST_MODULE_SELF_SYM()
+
+struct ast_module;
+/* Internal/forward declaration, AST_MODULE_SELF should be used instead. */
+struct ast_module *AST_MODULE_SELF_SYM(void);
+
+#endif
+
 #endif /* _ASTERISK_H */
index 6171dd4..3975fda 100644 (file)
@@ -584,7 +584,7 @@ int ast_vm_is_registered(void);
 int __ast_vm_register(const struct ast_vm_functions *vm_table, struct ast_module *module);
 
 /*! \brief See \ref __ast_vm_register() */
-#define ast_vm_register(vm_table) __ast_vm_register(vm_table, ast_module_info ? ast_module_info->self : NULL)
+#define ast_vm_register(vm_table) __ast_vm_register(vm_table, AST_MODULE_SELF)
 
 /*!
  * \brief Unregister the specified voicemail provider
@@ -652,7 +652,7 @@ int ast_vm_greeter_is_registered(void);
 int __ast_vm_greeter_register(const struct ast_vm_greeter_functions *vm_table, struct ast_module *module);
 
 /*! \brief See \ref __ast_vm_greeter_register() */
-#define ast_vm_greeter_register(vm_table) __ast_vm_greeter_register(vm_table, ast_module_info ? ast_module_info->self : NULL)
+#define ast_vm_greeter_register(vm_table) __ast_vm_greeter_register(vm_table, AST_MODULE_SELF)
 
 /*!
  * \brief Unregister the specified voicemail greeter provider
index 01031e3..b83a51b 100644 (file)
@@ -182,7 +182,7 @@ struct ast_bridge_technology {
 int __ast_bridge_technology_register(struct ast_bridge_technology *technology, struct ast_module *mod);
 
 /*! \brief See \ref __ast_bridge_technology_register() */
-#define ast_bridge_technology_register(technology) __ast_bridge_technology_register(technology, ast_module_info->self)
+#define ast_bridge_technology_register(technology) __ast_bridge_technology_register(technology, AST_MODULE_SELF)
 
 /*!
  * \brief Unregister a bridge technology from use
index c07fb0c..da83759 100644 (file)
@@ -134,7 +134,7 @@ int ast_bucket_init(void);
  *
  * \note Once a scheme has been registered it can not be unregistered
  */
-#define ast_bucket_scheme_register(name, bucket, file, create_cb, destroy_cb) __ast_bucket_scheme_register(name, bucket, file, create_cb, destroy_cb, ast_module_info ? ast_module_info->self : NULL)
+#define ast_bucket_scheme_register(name, bucket, file, create_cb, destroy_cb) __ast_bucket_scheme_register(name, bucket, file, create_cb, destroy_cb, AST_MODULE_SELF)
 
 /*!
  * \brief Register support for a specific scheme
index 458ebc8..82363c1 100644 (file)
@@ -177,7 +177,7 @@ struct ast_cli_entry {
        const char * usage;                             /*!< Detailed usage information */
 
        int inuse;                              /*!< For keeping track of usage */
-       struct module *module;                  /*!< module this belongs to */
+       struct ast_module *module;                      /*!< module this belongs to */
        char *_full_cmd;                        /*!< built at load time from cmda[] */
        int cmdlen;                             /*!< len up to the first invalid char [<{% */
        /*! \brief This gets set in ast_cli_register()
@@ -253,14 +253,19 @@ int ast_cli_command_multiple_full(int uid, int gid, int fd, size_t size, const c
  * \retval 0 on success
  * \retval -1 on failure
  */
-int ast_cli_register(struct ast_cli_entry *e);
+#define ast_cli_register(e) __ast_cli_register(e, AST_MODULE_SELF)
+
+int __ast_cli_register(struct ast_cli_entry *e, struct ast_module *mod);
 
 /*!
  * \brief Register multiple commands
  * \param e pointer to first cli entry to register
  * \param len number of entries to register
  */
-int ast_cli_register_multiple(struct ast_cli_entry *e, int len);
+#define ast_cli_register_multiple(e, len) \
+       __ast_cli_register_multiple(e, len, AST_MODULE_SELF)
+
+int __ast_cli_register_multiple(struct ast_cli_entry *e, int len, struct ast_module *mod);
 
 /*! 
  * \brief Unregisters a command or an array of commands
index 28befec..3873324 100644 (file)
@@ -116,7 +116,7 @@ int __ast_codec_register(struct ast_codec *codec, struct ast_module *mod);
  * \retval 0 success
  * \retval -1 failure
  */
-#define ast_codec_register(codec) __ast_codec_register(codec, ast_module_info->self)
+#define ast_codec_register(codec) __ast_codec_register(codec, AST_MODULE_SELF)
 
 /*!
  * \brief Retrieve a codec given a name, type, and sample rate
index 3676b8d..d6da1f7 100644 (file)
@@ -360,7 +360,7 @@ struct ast_data_mapping_structure {
  */
 int __ast_data_register(const char *path, const struct ast_data_handler *handler,
        const char *registrar, struct ast_module *mod);
-#define ast_data_register(path, handler) __ast_data_register(path, handler, __FILE__, ast_module_info->self)
+#define ast_data_register(path, handler) __ast_data_register(path, handler, __FILE__, AST_MODULE_SELF)
 #define ast_data_register_core(path, handler) __ast_data_register(path, handler, __FILE__, NULL)
 
 /*!
@@ -376,7 +376,7 @@ int __ast_data_register(const char *path, const struct ast_data_handler *handler
 int __ast_data_register_multiple(const struct ast_data_entry *data_entries,
        size_t entries, const char *registrar, struct ast_module *mod);
 #define ast_data_register_multiple(data_entries, entries) \
-       __ast_data_register_multiple(data_entries, entries, __FILE__, ast_module_info->self)
+       __ast_data_register_multiple(data_entries, entries, __FILE__, AST_MODULE_SELF)
 #define ast_data_register_multiple_core(data_entries, entries) \
        __ast_data_register_multiple(data_entries, entries, __FILE__, NULL)
 
index 3da2d82..c99c8f3 100644 (file)
@@ -247,7 +247,7 @@ int __ast_format_interface_register(const char *codec, const struct ast_format_i
  * \retval 0 success
  * \retval -1 failure
  */
-#define ast_format_interface_register(codec, interface) __ast_format_interface_register(codec, interface, ast_module_info->self)
+#define ast_format_interface_register(codec, interface) __ast_format_interface_register(codec, interface, AST_MODULE_SELF)
 
 /*!
  * \brief Get the attribute data on a format
index b5ede54..1ec1cba 100644 (file)
@@ -180,10 +180,10 @@ struct manager_action {
 
 /*! \brief External routines may register/unregister manager callbacks this way 
  * \note  Use ast_manager_register2() to register with help text for new manager commands */
-#define ast_manager_register(action, authority, func, synopsis) ast_manager_register2(action, authority, func, ast_module_info->self, synopsis, NULL)
+#define ast_manager_register(action, authority, func, synopsis) ast_manager_register2(action, authority, func, AST_MODULE_SELF, synopsis, NULL)
 
 /*! \brief Register a manager callback using XML documentation to describe the manager. */
-#define ast_manager_register_xml(action, authority, func) ast_manager_register2(action, authority, func, ast_module_info->self, NULL, NULL)
+#define ast_manager_register_xml(action, authority, func) ast_manager_register2(action, authority, func, AST_MODULE_SELF, NULL, NULL)
 
 /*!
  * \brief Register a manager callback using XML documentation to describe the manager.
index 7f17741..bcd31de 100644 (file)
@@ -128,7 +128,7 @@ struct ast_filestream {
  * \retval -1 on failure
  */
 int __ast_format_def_register(const struct ast_format_def *f, struct ast_module *mod);
-#define ast_format_def_register(f) __ast_format_def_register(f, ast_module_info->self)
+#define ast_format_def_register(f) __ast_format_def_register(f, AST_MODULE_SELF)
 
 /*! 
  * \brief Unregisters a file format 
index 6d5e04d..f427491 100644 (file)
@@ -312,9 +312,9 @@ struct ast_module_user *__ast_module_user_add(struct ast_module *, struct ast_ch
 void __ast_module_user_remove(struct ast_module *, struct ast_module_user *);
 void __ast_module_user_hangup_all(struct ast_module *);
 
-#define ast_module_user_add(chan) __ast_module_user_add(ast_module_info->self, chan)
-#define ast_module_user_remove(user) __ast_module_user_remove(ast_module_info->self, user)
-#define ast_module_user_hangup_all() __ast_module_user_hangup_all(ast_module_info->self)
+#define ast_module_user_add(chan) __ast_module_user_add(AST_MODULE_SELF, chan)
+#define ast_module_user_remove(user) __ast_module_user_remove(AST_MODULE_SELF, user)
+#define ast_module_user_hangup_all() __ast_module_user_hangup_all(AST_MODULE_SELF)
 
 struct ast_module *__ast_module_ref(struct ast_module *mod, const char *file, int line, const char *func);
 void __ast_module_shutdown_ref(struct ast_module *mod, const char *file, int line, const char *func);
@@ -368,8 +368,13 @@ void __ast_module_unref(struct ast_module *mod, const char *file, int line, cons
        {                                                                  \
                ast_module_unregister(&__mod_info);                            \
        }                                                                  \
+       struct ast_module *AST_MODULE_SELF_SYM(void)                       \
+       {                                                                  \
+               return __mod_info.self;                                        \
+       }                                                                  \
        static const __attribute__((unused)) struct ast_module_info *ast_module_info = &__mod_info
 
+
 #define AST_MODULE_INFO_STANDARD(keystr, desc)              \
        AST_MODULE_INFO(keystr, AST_MODFLAG_LOAD_ORDER, desc,   \
                        load_module,                                    \
@@ -401,7 +406,9 @@ void __ast_module_unref(struct ast_module *mod, const char *file, int line, cons
 /* forward declare this pointer in modules, so that macro/function
    calls that need it can get it, since it will actually be declared
    and populated at the end of the module's source file... */
+#if !defined(AST_IN_CORE)
 static const __attribute__((unused)) struct ast_module_info *ast_module_info;
+#endif
 
 #if !defined(EMBEDDED_MODULE)
 #define __MODULE_INFO_SECTION
@@ -482,6 +489,10 @@ static void __restore_globals(void)
        { \
                ast_module_unregister(&__mod_info); \
        } \
+       struct ast_module *AST_MODULE_SELF_SYM(void)                       \
+       {                                                                  \
+               return __mod_info.self;                                        \
+       }                                                                  \
        static const struct ast_module_info *ast_module_info = &__mod_info
 
 #define AST_MODULE_INFO_STANDARD(keystr, desc)              \
@@ -527,7 +538,7 @@ static void __restore_globals(void)
  * \retval 0 success 
  * \retval -1 failure.
  */
-#define ast_register_application(app, execute, synopsis, description) ast_register_application2(app, execute, synopsis, description, ast_module_info->self)
+#define ast_register_application(app, execute, synopsis, description) ast_register_application2(app, execute, synopsis, description, AST_MODULE_SELF)
 
 /*! 
  * \brief Register an application using XML documentation.
index a8832cd..4c93c3b 100644 (file)
@@ -196,7 +196,7 @@ struct ast_parking_bridge_feature_fn_table {
        int (* parking_park_bridge_channel)(struct ast_bridge_channel *parkee, const char *parkee_uuid, const char *parker_uuid, const char *app_data);
 
        /*! \brief The module info for the module registering this parking provider */
-       const struct ast_module_info *module_info;
+       struct ast_module *module;
 };
 
 /*!
index 795af05..c09de98 100644 (file)
@@ -1406,7 +1406,7 @@ enum ast_custom_function_escalation {
 /*!
  * \brief Register a custom function
  */
-#define ast_custom_function_register(acf) __ast_custom_function_register(acf, ast_module_info->self)
+#define ast_custom_function_register(acf) __ast_custom_function_register(acf, AST_MODULE_SELF)
 
 /*!
  * \brief Register a custom function which requires escalated privileges.
@@ -1415,7 +1415,7 @@ enum ast_custom_function_escalation {
  * arbitrary code) or FILE() (for which write needs permission to change files
  * on the filesystem).
  */
-#define ast_custom_function_register_escalating(acf, escalation) __ast_custom_function_register_escalating(acf, escalation, ast_module_info->self)
+#define ast_custom_function_register_escalating(acf, escalation) __ast_custom_function_register_escalating(acf, escalation, AST_MODULE_SELF)
 
 /*!
  * \brief Register a custom function
index a1a17da..a94cb42 100644 (file)
@@ -643,7 +643,7 @@ struct ast_rtp_glue {
  */
 struct ast_rtp_payload_type *ast_rtp_engine_alloc_payload_type(void);
 
-#define ast_rtp_engine_register(engine) ast_rtp_engine_register2(engine, ast_module_info->self)
+#define ast_rtp_engine_register(engine) ast_rtp_engine_register2(engine, AST_MODULE_SELF)
 
 /*!
  * \brief Register an RTP engine
@@ -696,7 +696,7 @@ int ast_rtp_engine_register_srtp(struct ast_srtp_res *srtp_res, struct ast_srtp_
 void ast_rtp_engine_unregister_srtp(void);
 int ast_rtp_engine_srtp_is_registered(void);
 
-#define ast_rtp_glue_register(glue) ast_rtp_glue_register2(glue, ast_module_info->self)
+#define ast_rtp_glue_register(glue) ast_rtp_glue_register2(glue, AST_MODULE_SELF)
 
 /*!
  * \brief Register RTP glue
index 874dac2..a5061c6 100644 (file)
@@ -366,7 +366,7 @@ int __ast_sorcery_wizard_register(const struct ast_sorcery_wizard *interface, st
 /*!
  * \brief See \ref __ast_sorcery_wizard_register()
  */
-#define ast_sorcery_wizard_register(interface) __ast_sorcery_wizard_register(interface, ast_module_info ? ast_module_info->self : NULL)
+#define ast_sorcery_wizard_register(interface) __ast_sorcery_wizard_register(interface, AST_MODULE_SELF)
 
 /*!
  * \brief Unregister a sorcery wizard
index ff4947a..2682003 100644 (file)
@@ -92,7 +92,7 @@ struct ast_timing_interface {
  * \retval non-Null handle to be passed to ast_unregister_timing_interface() on success
  * \since 1.6.1
  */
-#define ast_register_timing_interface(i) _ast_register_timing_interface(i, ast_module_info->self)
+#define ast_register_timing_interface(i) _ast_register_timing_interface(i, AST_MODULE_SELF)
 void *_ast_register_timing_interface(struct ast_timing_interface *funcs,
                                                 struct ast_module *mod);
 
index e8e4c02..87e9a2c 100644 (file)
@@ -241,7 +241,7 @@ struct ast_trans_pvt;
 int __ast_register_translator(struct ast_translator *t, struct ast_module *module);
 
 /*! \brief See \ref __ast_register_translator() */
-#define ast_register_translator(t) __ast_register_translator(t, ast_module_info->self)
+#define ast_register_translator(t) __ast_register_translator(t, AST_MODULE_SELF)
 
 /*!
  * \brief Unregister a translator
index c0c0aff..08496e6 100644 (file)
@@ -201,7 +201,7 @@ ifeq ($(findstring darwin,$(OSARCH)),) # not Darwin
 ASTSSL_LIB:=libasteriskssl.so
 
 $(ASTSSL_LIB).$(ASTSSL_SO_VERSION): _ASTLDFLAGS+=-Wl,-soname=$(ASTSSL_LIB).$(ASTSSL_SO_VERSION)
-$(ASTSSL_LIB).$(ASTSSL_SO_VERSION): _ASTCFLAGS+=-fPIC -DAST_MODULE=\"asteriskssl\"
+$(ASTSSL_LIB).$(ASTSSL_SO_VERSION): _ASTCFLAGS+=-fPIC -DAST_MODULE=\"asteriskssl\" -DAST_NOT_MODULE
 $(ASTSSL_LIB).$(ASTSSL_SO_VERSION): LIBS+=$(ASTSSL_LIBS)
 ifeq ($(GNU_LD),1)
     $(ASTSSL_LIB).$(ASTSSL_SO_VERSION): SO_SUPPRESS_SYMBOLS=-Wl,--version-script,libasteriskssl.exports,--warn-common
index c48db5c..5e20f30 100644 (file)
@@ -606,18 +606,17 @@ static int setup_dynamic_feature(void *obj, void *arg, void *data, int flags)
  */
 static int setup_bridge_features_dynamic(struct ast_bridge_features *features, struct ast_channel *chan)
 {
-       RAII_VAR(struct ao2_container *, applicationmap, NULL, ao2_cleanup);
+       struct ao2_container *applicationmap;
        int res = 0;
 
        ast_channel_lock(chan);
        applicationmap = ast_get_chan_applicationmap(chan);
        ast_channel_unlock(chan);
-       if (!applicationmap) {
-               return 0;
+       if (applicationmap) {
+               ao2_callback_data(applicationmap, 0, setup_dynamic_feature, features, &res);
+               ao2_ref(applicationmap, -1);
        }
 
-       ao2_callback_data(applicationmap, 0, setup_dynamic_feature, features, &res);
-
        return res;
 }
 
@@ -1418,7 +1417,7 @@ static struct attended_transfer_properties *attended_transfer_properties_alloc(
        char *tech;
        char *addr;
        char *serial;
-       RAII_VAR(struct ast_features_xfer_config *, xfer_cfg, NULL, ao2_cleanup);
+       struct ast_features_xfer_config *xfer_cfg;
        struct ast_flags *transferer_features;
 
        props = ao2_alloc(sizeof(*props), attended_transfer_properties_destructor);
@@ -1450,6 +1449,7 @@ static struct attended_transfer_properties *attended_transfer_properties_alloc(
        ast_string_field_set(props, context, get_transfer_context(transferer, context));
        ast_string_field_set(props, failsound, xfer_cfg->xferfailsound);
        ast_string_field_set(props, xfersound, xfer_cfg->xfersound);
+       ao2_ref(xfer_cfg, -1);
 
        /*
         * Save the transferee's party information for any recall calls.
@@ -1695,17 +1695,16 @@ static void publish_transfer_fail(struct attended_transfer_properties *props)
  */
 static void play_sound(struct ast_channel *chan, const char *sound)
 {
-       RAII_VAR(struct ast_bridge_channel *, bridge_channel, NULL, ao2_cleanup);
+       struct ast_bridge_channel *bridge_channel;
 
        ast_channel_lock(chan);
        bridge_channel = ast_channel_get_bridge_channel(chan);
        ast_channel_unlock(chan);
 
-       if (!bridge_channel) {
-               return;
+       if (bridge_channel) {
+               ast_bridge_channel_queue_playfile(bridge_channel, NULL, sound, NULL);
+               ao2_ref(bridge_channel, -1);
        }
-
-       ast_bridge_channel_queue_playfile(bridge_channel, NULL, sound, NULL);
 }
 
 /*!
@@ -1713,16 +1712,19 @@ static void play_sound(struct ast_channel *chan, const char *sound)
  */
 static void hold(struct ast_channel *chan)
 {
-       RAII_VAR(struct ast_bridge_channel *, bridge_channel, NULL, ao2_cleanup);
+       struct ast_bridge_channel *bridge_channel;
 
-       if (chan) {
-               ast_channel_lock(chan);
-               bridge_channel = ast_channel_get_bridge_channel(chan);
-               ast_channel_unlock(chan);
+       if (!chan) {
+               return;
+       }
 
-               ast_assert(bridge_channel != NULL);
+       ast_channel_lock(chan);
+       bridge_channel = ast_channel_get_bridge_channel(chan);
+       ast_channel_unlock(chan);
 
+       if (bridge_channel) {
                ast_bridge_channel_write_hold(bridge_channel, NULL);
+               ao2_ref(bridge_channel, -1);
        }
 }
 
@@ -1731,15 +1733,20 @@ static void hold(struct ast_channel *chan)
  */
 static void unhold(struct ast_channel *chan)
 {
-       RAII_VAR(struct ast_bridge_channel *, bridge_channel, NULL, ao2_cleanup);
+       struct ast_bridge_channel *bridge_channel;
+
+       if (!chan) {
+               return;
+       }
 
        ast_channel_lock(chan);
        bridge_channel = ast_channel_get_bridge_channel(chan);
        ast_channel_unlock(chan);
 
-       ast_assert(bridge_channel != NULL);
-
-       ast_bridge_channel_write_unhold(bridge_channel);
+       if (bridge_channel) {
+               ast_bridge_channel_write_unhold(bridge_channel);
+               ao2_ref(bridge_channel, -1);
+       }
 }
 
 /*!
@@ -1747,15 +1754,16 @@ static void unhold(struct ast_channel *chan)
  */
 static void ringing(struct ast_channel *chan)
 {
-       RAII_VAR(struct ast_bridge_channel *, bridge_channel, NULL, ao2_cleanup);
+       struct ast_bridge_channel *bridge_channel;
 
        ast_channel_lock(chan);
        bridge_channel = ast_channel_get_bridge_channel(chan);
        ast_channel_unlock(chan);
 
-       ast_assert(bridge_channel != NULL);
-
-       ast_bridge_channel_write_control_data(bridge_channel, AST_CONTROL_RINGING, NULL, 0);
+       if (bridge_channel) {
+               ast_bridge_channel_write_control_data(bridge_channel, AST_CONTROL_RINGING, NULL, 0);
+               ao2_ref(bridge_channel, -1);
+       }
 }
 
 /*!
@@ -1800,10 +1808,9 @@ static void bridge_unhold(struct ast_bridge *bridge)
 /*!
  * \brief Wrapper for \ref bridge_do_move
  */
-static int bridge_move(struct ast_bridge *dest, struct ast_bridge *src, struct ast_channel *channel, struct ast_channel *swap)
+static void bridge_move(struct ast_bridge *dest, struct ast_bridge *src, struct ast_channel *channel, struct ast_channel *swap)
 {
-       int res;
-       RAII_VAR(struct ast_bridge_channel *, bridge_channel, NULL, ao2_cleanup);
+       struct ast_bridge_channel *bridge_channel;
 
        ast_bridge_lock_both(src, dest);
 
@@ -1811,18 +1818,18 @@ static int bridge_move(struct ast_bridge *dest, struct ast_bridge *src, struct a
        bridge_channel = ast_channel_get_bridge_channel(channel);
        ast_channel_unlock(channel);
 
-       ast_assert(bridge_channel != NULL);
-
-       ao2_lock(bridge_channel);
-       bridge_channel->swap = swap;
-       ao2_unlock(bridge_channel);
+       if (bridge_channel) {
+               ao2_lock(bridge_channel);
+               bridge_channel->swap = swap;
+               ao2_unlock(bridge_channel);
 
-       res = bridge_do_move(dest, bridge_channel, 1, 0);
+               bridge_do_move(dest, bridge_channel, 1, 0);
+       }
 
        ast_bridge_unlock(dest);
        ast_bridge_unlock(src);
 
-       return res;
+       ao2_cleanup(bridge_channel);
 }
 
 /*!
@@ -2033,7 +2040,8 @@ static const struct attended_transfer_state_properties state_properties[] = {
 
 static int calling_target_enter(struct attended_transfer_properties *props)
 {
-       return bridge_move(props->target_bridge, props->transferee_bridge, props->transferer, NULL);
+       bridge_move(props->target_bridge, props->transferee_bridge, props->transferer, NULL);
+       return 0;
 }
 
 static enum attended_transfer_state calling_target_exit(struct attended_transfer_properties *props,
@@ -2072,10 +2080,7 @@ static enum attended_transfer_state calling_target_exit(struct attended_transfer
 
 static int hesitant_enter(struct attended_transfer_properties *props)
 {
-       if (bridge_move(props->transferee_bridge, props->target_bridge, props->transferer, NULL)) {
-               return -1;
-       }
-
+       bridge_move(props->transferee_bridge, props->target_bridge, props->transferer, NULL);
        unhold(props->transferer);
        return 0;
 }
@@ -2115,11 +2120,7 @@ static enum attended_transfer_state hesitant_exit(struct attended_transfer_prope
 
 static int rebridge_enter(struct attended_transfer_properties *props)
 {
-       if (bridge_move(props->transferee_bridge, props->target_bridge,
-                       props->transferer, NULL)) {
-               return -1;
-       }
-
+       bridge_move(props->transferee_bridge, props->target_bridge, props->transferer, NULL);
        unhold(props->transferer);
        return 0;
 }
@@ -2839,7 +2840,8 @@ static void transfer_pull(struct ast_bridge *self, struct ast_bridge_channel *br
        }
 
        if (self->num_channels == 1) {
-               RAII_VAR(struct ast_bridge_channel *, transferer_bridge_channel, NULL, ao2_cleanup);
+               struct ast_bridge_channel *transferer_bridge_channel;
+               int not_transferer;
 
                ast_channel_lock(props->transferer);
                transferer_bridge_channel = ast_channel_get_bridge_channel(props->transferer);
@@ -2849,7 +2851,9 @@ static void transfer_pull(struct ast_bridge *self, struct ast_bridge_channel *br
                        return;
                }
 
-               if (AST_LIST_FIRST(&self->channels) != transferer_bridge_channel) {
+               not_transferer = AST_LIST_FIRST(&self->channels) != transferer_bridge_channel;
+               ao2_ref(transferer_bridge_channel, -1);
+               if (not_transferer) {
                        return;
                }
        }
@@ -2886,7 +2890,8 @@ static void recall_pull(struct ast_bridge *self, struct ast_bridge_channel *brid
        }
 
        if (self->num_channels == 1) {
-               RAII_VAR(struct ast_bridge_channel *, target_bridge_channel, NULL, ao2_cleanup);
+               struct ast_bridge_channel *target_bridge_channel;
+
                if (!props->recall_target) {
                        /* No recall target means that the pull happened on a transferee. If there's still
                         * a channel left in the bridge, we don't need to send a stimulus
@@ -2898,12 +2903,11 @@ static void recall_pull(struct ast_bridge *self, struct ast_bridge_channel *brid
                target_bridge_channel = ast_channel_get_bridge_channel(props->recall_target);
                ast_channel_unlock(props->recall_target);
 
-               if (!target_bridge_channel) {
-                       return;
-               }
-
-               if (AST_LIST_FIRST(&self->channels) == target_bridge_channel) {
-                       stimulate_attended_transfer(props, STIMULUS_TRANSFEREE_HANGUP);
+               if (target_bridge_channel) {
+                       if (AST_LIST_FIRST(&self->channels) == target_bridge_channel) {
+                               stimulate_attended_transfer(props, STIMULUS_TRANSFEREE_HANGUP);
+                       }
+                       ao2_ref(target_bridge_channel, -1);
                }
        }
 }
@@ -2925,7 +2929,8 @@ static void bridge_personality_atxfer_pull(struct ast_bridge *self, struct ast_b
 
 static enum attended_transfer_stimulus wait_for_stimulus(struct attended_transfer_properties *props)
 {
-       RAII_VAR(struct stimulus_list *, list, NULL, ast_free_ptr);
+       enum attended_transfer_stimulus stimulus;
+       struct stimulus_list *list;
        SCOPED_MUTEX(lock, ao2_object_get_lockaddr(props));
 
        while (!(list = AST_LIST_REMOVE_HEAD(&props->stimulus_queue, next))) {
@@ -2956,7 +2961,9 @@ static enum attended_transfer_stimulus wait_for_stimulus(struct attended_transfe
                        }
                }
        }
-       return list->stimulus;
+       stimulus = list->stimulus;
+       ast_free(list);
+       return stimulus;
 }
 
 /*!
@@ -3050,7 +3057,7 @@ static int add_transferer_role(struct ast_channel *chan, struct ast_bridge_featu
        const char *atxfer_threeway;
        const char *atxfer_complete;
        const char *atxfer_swap;
-       RAII_VAR(struct ast_features_xfer_config *, xfer_cfg, NULL, ao2_cleanup);
+       struct ast_features_xfer_config *xfer_cfg;
        SCOPED_CHANNELLOCK(lock, chan);
 
        xfer_cfg = ast_get_chan_features_xfer_config(chan);
@@ -3068,6 +3075,7 @@ static int add_transferer_role(struct ast_channel *chan, struct ast_bridge_featu
                atxfer_complete = ast_strdupa(xfer_cfg->atxfercomplete);
                atxfer_swap = ast_strdupa(xfer_cfg->atxferswap);
        }
+       ao2_ref(xfer_cfg, -1);
 
        return ast_channel_add_bridge_role(chan, AST_TRANSFERER_ROLE_NAME) ||
                ast_channel_set_bridge_role_option(chan, AST_TRANSFERER_ROLE_NAME, "abort", atxfer_abort) ||
@@ -3088,7 +3096,7 @@ static int grab_transfer(struct ast_channel *chan, char *exten, size_t exten_len
        int digit_timeout;
        int attempts = 0;
        int max_attempts;
-       RAII_VAR(struct ast_features_xfer_config *, xfer_cfg, NULL, ao2_cleanup);
+       struct ast_features_xfer_config *xfer_cfg;
        char *retry_sound;
        char *invalid_sound;
 
@@ -3103,6 +3111,7 @@ static int grab_transfer(struct ast_channel *chan, char *exten, size_t exten_len
        max_attempts = xfer_cfg->transferdialattempts;
        retry_sound = ast_strdupa(xfer_cfg->transferretrysound);
        invalid_sound = ast_strdupa(xfer_cfg->transferinvalidsound);
+       ao2_ref(xfer_cfg, -1);
        ast_channel_unlock(chan);
 
        /* Play the simple "transfer" prompt out and wait */
index a230c20..eb8800f 100644 (file)
@@ -2203,7 +2203,7 @@ static int cli_is_registered(struct ast_cli_entry *e)
        return 0;
 }
 
-static int __ast_cli_unregister(struct ast_cli_entry *e, struct ast_cli_entry *ed)
+int ast_cli_unregister(struct ast_cli_entry *e)
 {
        if (e->inuse) {
                ast_log(LOG_WARNING, "Can't remove command that is in use\n");
@@ -2225,7 +2225,7 @@ static int __ast_cli_unregister(struct ast_cli_entry *e, struct ast_cli_entry *e
        return 0;
 }
 
-static int __ast_cli_register(struct ast_cli_entry *e, struct ast_cli_entry *ed)
+int __ast_cli_register(struct ast_cli_entry *e, struct ast_module *module)
 {
        struct ast_cli_entry *cur;
        int i, lf, ret = -1;
@@ -2244,7 +2244,11 @@ static int __ast_cli_register(struct ast_cli_entry *e, struct ast_cli_entry *ed)
        }
 
        memset(&a, '\0', sizeof(a));
+
+       e->module = module;
+       /* No module reference needed here, the module called us. */
        e->handler(e, CLI_INIT, &a);
+
        /* XXX check that usage and command are filled up */
        s = ast_skip_blanks(e->command);
        s = e->command = ast_strdup(s);
@@ -2295,27 +2299,16 @@ done:
        return ret;
 }
 
-/* wrapper function, so we can unregister deprecated commands recursively */
-int ast_cli_unregister(struct ast_cli_entry *e)
-{
-       return __ast_cli_unregister(e, NULL);
-}
-
-/* wrapper function, so we can register deprecated commands recursively */
-int ast_cli_register(struct ast_cli_entry *e)
-{
-       return __ast_cli_register(e, NULL);
-}
-
 /*
  * register/unregister an array of entries.
  */
-int ast_cli_register_multiple(struct ast_cli_entry *e, int len)
+int __ast_cli_register_multiple(struct ast_cli_entry *e, int len, struct ast_module *module)
 {
        int i, res = 0;
 
-       for (i = 0; i < len; i++)
-               res |= ast_cli_register(e + i);
+       for (i = 0; i < len; i++) {
+               res |= __ast_cli_register(e + i, module);
+       }
 
        return res;
 }
@@ -2657,7 +2650,9 @@ static char *__ast_cli_generator(const char *text, const char *word, int state,
                                        .n = state - matchnum,
                                        .argv = argv,
                                        .argc = x};
+                               ast_module_ref(e->module);
                                ret = e->handler(e, CLI_GENERATE, &a);
+                               ast_module_unref(e->module);
                        }
                        if (ret)
                                break;
@@ -2714,7 +2709,9 @@ int ast_cli_command_full(int uid, int gid, int fd, const char *s)
         */
        args[0] = (char *)e;
 
+       ast_module_ref(e->module);
        retval = e->handler(e, CLI_HANDLER, &a);
+       ast_module_unref(e->module);
 
        if (retval == CLI_SHOWUSAGE) {
                ast_cli(fd, "%s", S_OR(e->usage, "Invalid usage, but no usage information available.\n"));
index 06790ff..7603465 100644 (file)
@@ -93,33 +93,6 @@ void SSL_load_error_strings(void)
 #endif
 }
 
-void ERR_load_SSL_strings(void)
-{
-#if defined(AST_DEVMODE)
-       if (startup_complete) {
-               ast_debug(1, "Called after startup... ignoring!\n");
-       }
-#endif
-}
-
-void ERR_load_crypto_strings(void)
-{
-#if defined(AST_DEVMODE)
-       if (startup_complete) {
-               ast_debug(1, "Called after startup... ignoring!\n");
-       }
-#endif
-}
-
-void ERR_load_BIO_strings(void)
-{
-#if defined(AST_DEVMODE)
-       if (startup_complete) {
-               ast_debug(1, "Called after startup... ignoring!\n");
-       }
-#endif
-}
-
 void CRYPTO_set_id_callback(unsigned long (*func)(void))
 {
 #if defined(AST_DEVMODE)
@@ -157,8 +130,6 @@ int ast_ssl_init(void)
        void (*real_CRYPTO_set_id_callback)(unsigned long (*)(void));
        void (*real_CRYPTO_set_locking_callback)(void (*)(int, int, const char *, int));
        void (*real_SSL_load_error_strings)(void);
-       void (*real_ERR_load_SSL_strings)(void);
-       void (*real_ERR_load_BIO_strings)(void);
        const char *errstr;
 
        /* clear any previous dynamic linker errors */
@@ -216,12 +187,6 @@ int ast_ssl_init(void)
        get_OpenSSL_function(SSL_load_error_strings);
        real_SSL_load_error_strings();
 
-       get_OpenSSL_function(ERR_load_SSL_strings);
-       real_ERR_load_SSL_strings();
-
-       get_OpenSSL_function(ERR_load_BIO_strings);
-       real_ERR_load_BIO_strings();
-
        startup_complete = 1;
 
 #endif /* HAVE_OPENSSL */
index 25fdfe8..61a4896 100644 (file)
@@ -134,8 +134,8 @@ int ast_parking_park_bridge_channel(struct ast_bridge_channel *parkee, const cha
                return -1;
        }
 
-       if (table->module_info) {
-               SCOPED_MODULE_USE(table->module_info->self);
+       if (table->module) {
+               SCOPED_MODULE_USE(table->module);
                return table->parking_park_bridge_channel(parkee, parkee_uuid, parker_uuid, app_data);
        }
 
@@ -153,8 +153,8 @@ int ast_parking_blind_transfer_park(struct ast_bridge_channel *parker,
                return -1;
        }
 
-       if (table->module_info) {
-               SCOPED_MODULE_USE(table->module_info->self);
+       if (table->module) {
+               SCOPED_MODULE_USE(table->module);
                return table->parking_blind_transfer_park(parker, context, exten, parked_channel_cb, parked_channel_data);
        }
 
@@ -170,8 +170,8 @@ int ast_parking_park_call(struct ast_bridge_channel *parker, char *exten, size_t
                return -1;
        }
 
-       if (table->module_info) {
-               SCOPED_MODULE_USE(table->module_info->self);
+       if (table->module) {
+               SCOPED_MODULE_USE(table->module);
                return table->parking_park_call(parker, exten, length);
        }
 
@@ -187,8 +187,8 @@ int ast_parking_is_exten_park(const char *context, const char *exten)
                return -1;
        }
 
-       if (table->module_info) {
-               SCOPED_MODULE_USE(table->module_info->self);
+       if (table->module) {
+               SCOPED_MODULE_USE(table->module);
                return table->parking_is_exten_park(context, exten);
        }
 
index ddeeeea..0b06d22 100644 (file)
@@ -400,7 +400,11 @@ static int tcptls_stream_close(void *cookie)
 
                        if (!stream->ssl->server) {
                                /* For client threads, ensure that the error stack is cleared */
+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+                               ERR_remove_thread_state(NULL);
+#else
                                ERR_remove_state(0);
+#endif /* OPENSSL_VERSION_NUMBER >= 0x10000000L */
                        }
 
                        SSL_free(stream->ssl);
index 762bf55..5077474 100644 (file)
@@ -868,8 +868,6 @@ static int park_and_announce_app_exec(struct ast_channel *chan, const char *data
 
 int load_parking_applications(void)
 {
-       const struct ast_module_info *ast_module_info = parking_get_module_info();
-
        if (ast_register_application_xml(PARK_APPLICATION, park_app_exec)) {
                return -1;
        }
index 4a01e4c..4cb87c8 100644 (file)
@@ -502,7 +502,7 @@ static int parking_park_call(struct ast_bridge_channel *parker, char *exten, siz
 
 static int feature_park_call(struct ast_bridge_channel *bridge_channel, void *hook_pvt)
 {
-       SCOPED_MODULE_USE(parking_get_module_info()->self);
+       SCOPED_MODULE_USE(AST_MODULE_SELF);
 
        return parking_park_call(bridge_channel, NULL, 0);
 }
@@ -726,7 +726,7 @@ void unload_parking_bridge_features(void)
 
 int load_parking_bridge_features(void)
 {
-       parking_provider.module_info = parking_get_module_info();
+       parking_provider.module = AST_MODULE_SELF;
 
        if (ast_parking_register_bridge_features(&parking_provider)) {
                return -1;
index ffa4bc7..175ae5f 100644 (file)
@@ -678,11 +678,10 @@ static void parking_manager_enable_stasis(void)
 int load_parking_manager(void)
 {
        int res;
-       const struct ast_module_info *module = parking_get_module_info();
 
-       res = ast_manager_register2("Parkinglots", EVENT_FLAG_CALL, manager_parking_lot_list, module->self, NULL, NULL);
-       res |= ast_manager_register2("ParkedCalls", EVENT_FLAG_CALL, manager_parking_status, module->self, NULL, NULL);
-       res |= ast_manager_register2("Park", EVENT_FLAG_CALL, manager_park, module->self, NULL, NULL);
+       res = ast_manager_register_xml("Parkinglots", EVENT_FLAG_CALL, manager_parking_lot_list);
+       res |= ast_manager_register_xml("ParkedCalls", EVENT_FLAG_CALL, manager_parking_status);
+       res |= ast_manager_register_xml("Park", EVENT_FLAG_CALL, manager_park);
        parking_manager_enable_stasis();
        return res ? -1 : 0;
 }
index 3d77e51..2c4a180 100644 (file)
@@ -560,12 +560,3 @@ int load_parking_tests(void);
  * \return Nothing
  */
 void unload_parking_tests(void);
-
-struct ast_module_info;
-/*!
- * \since 12.0.0
- * \brief Get res_parking's module info
- *
- * \retval res_parking's ast_module
- */
-const struct ast_module_info *parking_get_module_info(void);
index 173f9f5..451b174 100644 (file)
@@ -156,8 +156,6 @@ static char *handle_orig(struct ast_cli_entry *e, int cmd, struct ast_cli_args *
                        "used. If no extension is given, the 's' extension will be used.\n";
                return NULL;
        case CLI_GENERATE:
-               /* ugly, can be removed when CLI entries have ast_module pointers */
-               ast_module_ref(ast_module_info->self);
                if (a->pos == 3) {
                        res = ast_cli_complete(a->word, choices, a->n);
                } else if (a->pos == 4) {
@@ -165,16 +163,12 @@ static char *handle_orig(struct ast_cli_entry *e, int cmd, struct ast_cli_args *
                                res = ast_complete_applications(a->line, a->word, a->n);
                        }
                }
-               ast_module_unref(ast_module_info->self);
                return res;
        }
 
        if (ast_strlen_zero(a->argv[2]) || ast_strlen_zero(a->argv[3]))
                return CLI_SHOWUSAGE;
 
-       /* ugly, can be removed when CLI entries have ast_module pointers */
-       ast_module_ref(ast_module_info->self);
-
        if (!strcasecmp("application", a->argv[3])) {
                res = orig_app(a->fd, a->argv[2], a->argv[4], a->argv[5]);
        } else if (!strcasecmp("extension", a->argv[3])) {
@@ -183,8 +177,6 @@ static char *handle_orig(struct ast_cli_entry *e, int cmd, struct ast_cli_args *
                res = CLI_SHOWUSAGE;
        }
 
-       ast_module_unref(ast_module_info->self);
-
        return res;
 }
 
index 2a691a5..3ca5965 100644 (file)
@@ -88,9 +88,6 @@ static char *handle_cli_file_convert(struct ast_cli_entry *e, int cmd, struct as
                return NULL;
        }
        
-       /* ugly, can be removed when CLI entries have ast_module pointers */
-       ast_module_ref(ast_module_info->self);
-
        if (a->argc != 4 || ast_strlen_zero(a->argv[2]) || ast_strlen_zero(a->argv[3])) {
                ret = CLI_SHOWUSAGE;
                goto fail_out;  
@@ -142,8 +139,6 @@ fail_out:
        if (fs_in) 
                ast_closestream(fs_in);
 
-       ast_module_unref(ast_module_info->self);
-
        return ret;
 }
 
index a40990e..02740da 100644 (file)
@@ -1159,11 +1159,6 @@ static void link_configured_disable_marked_lots(void)
        disable_marked_lots();
 }
 
-const struct ast_module_info *parking_get_module_info(void)
-{
-       return ast_module_info;
-}
-
 static int unload_module(void)
 {
        unload_parking_bridge_features();
index 8be019f..a263809 100644 (file)
@@ -3650,7 +3650,7 @@ static int load_module(void)
 
        ast_sip_initialize_global_headers();
 
-       if (ast_res_pjsip_initialize_configuration(ast_module_info)) {
+       if (ast_res_pjsip_initialize_configuration()) {
                ast_log(LOG_ERROR, "Failed to initialize SIP configuration. Aborting load\n");
                ast_sip_destroy_global_headers();
                stop_monitor_thread();
index 5120fc6..a53e0c4 100644 (file)
@@ -25,7 +25,7 @@ struct ast_sip_cli_context;
  * \internal
  * \brief Initialize the configuration for res_pjsip
  */
-int ast_res_pjsip_initialize_configuration(const struct ast_module_info *ast_module_info);
+int ast_res_pjsip_initialize_configuration(void);
 
 /*!
  * \internal
index 54fdb65..f147b34 100644 (file)
@@ -1742,7 +1742,7 @@ static struct ast_cli_entry cli_commands[] = {
 struct ast_sip_cli_formatter_entry *channel_formatter;
 struct ast_sip_cli_formatter_entry *endpoint_formatter;
 
-int ast_res_pjsip_initialize_configuration(const struct ast_module_info *ast_module_info)
+int ast_res_pjsip_initialize_configuration(void)
 {
        if (ast_manager_register_xml(AMI_SHOW_ENDPOINTS, EVENT_FLAG_SYSTEM, ami_show_endpoints) ||
            ast_manager_register_xml(AMI_SHOW_ENDPOINT, EVENT_FLAG_SYSTEM, ami_show_endpoint)) {
index 8ffb88c..87c67fa 100644 (file)
@@ -1181,7 +1181,7 @@ int ast_res_pjsip_init_options_handling(int reload)
        }
 
        internal_sip_register_endpoint_formatter(&contact_status_formatter);
-       ast_manager_register2("PJSIPQualify", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, ami_sip_qualify, NULL, NULL, NULL);
+       ast_manager_register_xml("PJSIPQualify", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, ami_sip_qualify);
        ast_cli_register_multiple(cli_options, ARRAY_LEN(cli_options));
 
        qualify_and_schedule_all();
index 5311aed..68d76a4 100644 (file)
@@ -177,12 +177,28 @@ static struct ast_frame *snoop_read(struct ast_channel *chan)
        }
 
        /* Only get audio from the spy audiohook if it is active */
-       if (snoop->spy_active) {
-               ast_audiohook_lock(&snoop->spy);
-               frame = ast_audiohook_read_frame(&snoop->spy, snoop->spy_samples, snoop->spy_direction, snoop->spy_format);
-               ast_audiohook_unlock(&snoop->spy);
+       if (!snoop->spy_active) {
+               return &ast_null_frame;
        }
 
+       ast_audiohook_lock(&snoop->spy);
+       if (snoop->spy_direction != AST_AUDIOHOOK_DIRECTION_BOTH) {
+               /*
+                * When a singular direction is chosen frames are still written to the
+                * opposing direction's queue. Those frames must be read so the queue
+                * does not continue to grow, however since they are not needed for the
+                * selected direction they can be dropped.
+                */
+               enum ast_audiohook_direction opposing_direction =
+                       snoop->spy_direction == AST_AUDIOHOOK_DIRECTION_READ ?
+                       AST_AUDIOHOOK_DIRECTION_WRITE : AST_AUDIOHOOK_DIRECTION_READ;
+               ast_frame_dtor(ast_audiohook_read_frame(&snoop->spy, snoop->spy_samples,
+                                                       opposing_direction, snoop->spy_format));
+       }
+
+       frame = ast_audiohook_read_frame(&snoop->spy, snoop->spy_samples, snoop->spy_direction, snoop->spy_format);
+       ast_audiohook_unlock(&snoop->spy);
+
        return frame ? frame : &ast_null_frame;
 }
 
index af21673..97b0e2f 100644 (file)
@@ -150,6 +150,8 @@ pbx_ael.c: $(ASTTOPDIR)/pbx/pbx_ael.c
        $(CMD_PREFIX) sed 's/ast_debug([[:digit:]][[:digit:]]*/ast_log(LOG_DEBUG/' "$@" > "$@.new"
        $(CMD_PREFIX) mv "$@.new" "$@"
 
+pbx_ael.o: _ASTCFLAGS+=-DAST_MODULE_SELF_SYM=__internal_pbx_ael_self
+
 aelparse.c: $(ASTTOPDIR)/res/ael/ael_lex.c
        $(ECHO_PREFIX) echo "   [CP] $(subst $(ASTTOPDIR)/,,$<) -> $@"
        $(CMD_PREFIX) cp "$<" "$@"
index 2237625..06ba8e6 100644 (file)
@@ -103,7 +103,7 @@ static char var_dir[PATH_MAX];
 const char *ast_config_AST_CONFIG_DIR = config_dir;
 const char *ast_config_AST_VAR_DIR = var_dir;
 
-void ast_cli_register_multiple(void);
+void __ast_cli_register_multiple(void);
 int ast_add_extension2(struct ast_context *con,
                                           int replace, const char *extension, int priority, const char *label, const char *callerid,
                                                const char *application, void *data, void (*datad)(void *),
@@ -208,7 +208,7 @@ void ast_module_unregister(const struct ast_module_info *x)
 }
 
 
-void ast_cli_register_multiple(void)
+void __ast_cli_register_multiple(void)
 {
        if(!no_comp)
                printf("Executed ast_cli_register_multiple();\n");
index d25a710..426dd5c 100644 (file)
@@ -21,8 +21,8 @@ int ast_register_cleanup(void (*func)(void))
        return 0;
 }
 
-int ast_cli_register_multiple(struct ast_cli_entry *e, int len);
-int ast_cli_register_multiple(struct ast_cli_entry *e, int len)
+int __ast_cli_register_multiple(struct ast_cli_entry *e, int len);
+int __ast_cli_register_multiple(struct ast_cli_entry *e, int len)
 {
        return 0;
 }
index 99304b2..76a3ad3 100644 (file)
@@ -605,9 +605,9 @@ struct ast_context *ast_context_find_or_create(struct ast_context **extcontexts,
        return localized_context_find_or_create(extcontexts, exttable, name, registrar);
 }
 
-void ast_cli_register_multiple(void);
+void __ast_cli_register_multiple(void);
 
-void ast_cli_register_multiple(void)
+void __ast_cli_register_multiple(void)
 {
 }