Alternate Channel Storage Backends

Full details: http://s.asterisk.net/dc679ec3

The previous proof-of-concept showed that the cpp_map_name_id alternate
storage backed performed better than all the others so this final PR
adds only that option.  You still need to enable it in menuselect under
the "Alternate Channel Storage Backends" category.

To select which one is used at runtime, set the "channel_storage_backend"
option in asterisk.conf to one of the values described in
asterisk.conf.sample.  The default remains "ao2_legacy".

UpgradeNote: With this release, you can now select an alternate channel
storage backend based on C++ Maps.  Using the new backend may increase
performance and reduce the chances of deadlocks on heavily loaded systems.
For more information, see http://s.asterisk.net/dc679ec3
This commit is contained in:
George Joseph
2024-12-31 11:27:02 -07:00
committed by github-actions[bot]
parent 76ab68b7e9
commit f75dc57006
16 changed files with 2020 additions and 414 deletions

View File

@@ -1455,15 +1455,17 @@ int ast_queue_answer(struct ast_channel *chan, const struct ast_stream_topology
/*!
* \brief Change channel name
*
* \pre Absolutely all channels _MUST_ be unlocked before calling this function.
* \pre Absolutely all channels and the channel storage backend _MUST_ be
* unlocked before calling this function.
*
* \param chan the channel to change the name of
* \param newname the name to change to
*
* \note this function must _NEVER_ be used when any channels are locked
* regardless if it is the channel who's name is being changed or not because
* it invalidates our channel container locking order... lock container first,
* then the individual channels, never the other way around.
* \note this function must _NEVER_ be used when any channels or the channel
* storage backend are locked regardless if it is the channel who's name is
* being changed or not because it invalidates our channel container locking
* order... lock container first, then the individual channels, never the
* other way around.
*/
void ast_change_name(struct ast_channel *chan, const char *newname);
@@ -3119,6 +3121,13 @@ struct ast_channel *ast_channel_iterator_next(struct ast_channel_iterator *i);
/*! @} End channel iterator definitions. */
/*! @{ Channel search functions */
/*!
* \warning Absolutely _NO_ channel locks should be held while calling any of
* these functions.
*/
/*!
* \brief Call a function with every active channel
*
@@ -3126,41 +3135,50 @@ struct ast_channel *ast_channel_iterator_next(struct ast_channel_iterator *i);
* This function executes a callback one time for each active channel on the
* system. The channel is provided as an argument to the function.
*
* \note Absolutely _NO_ channel locks should be held before calling this function.
* \since 1.8
*/
struct ast_channel *ast_channel_callback(ao2_callback_data_fn *cb_fn, void *arg,
void *data, int ao2_flags);
/*! @{ Channel search functions */
/*!
* \brief Find a channel by name
* \brief Find a channel by name or uniqueid
*
* \param name the name or uniqueid of the channel to search for
* \param search the name or uniqueid of the channel to search for
*
* \details
* Find a channel that has the same name as the provided argument.
* First searches for a channel with a matching name. If not found
* a search for a channel with a matching uniqueid is done.
*
* \retval a channel with the name specified by the argument
* \retval a channel with a matching name or uniqueid
* \retval NULL if no channel was found
*
*\note The fallback search by uniqueid is a historical thing. If you
* know the search term is a uniqueid, use \ref ast_channel_get_by_uniqueid
* instead.
*
* \since 1.8
*/
struct ast_channel *ast_channel_get_by_name(const char *name);
struct ast_channel *ast_channel_get_by_name(const char *search);
/*!
* \brief Find a channel by a name prefix
*
* \param name The channel name or uniqueid prefix to search for
* \param name_len Only search for up to this many characters from the name
* \param search The channel name or uniqueid prefix to search for
* \param len Only search for up to this many characters from the search term
*
* \details
* Find a channel that has the same name prefix as specified by the arguments.
* Search for a channel that has the same name prefix as specified by the
* search term. If not found, search for an exact match on the uniqueid.
* Searching by partial uniqueid doesn't make any sense as it's usually
* a system-name plus a timestamp and is not supported.
*
* \retval a channel with the name prefix specified by the arguments
* \retval a channel with a matching name or uniqueid
* \retval NULL if no channel was found
*
*\note The fallback search by uniqueid is a historical thing. If you
* know the search term is a uniqueid, use \ref ast_channel_get_by_uniqueid
* instead.
*
* \since 1.8
*/
struct ast_channel *ast_channel_get_by_name_prefix(const char *name, size_t name_len);
@@ -3181,6 +3199,16 @@ struct ast_channel *ast_channel_get_by_name_prefix(const char *name, size_t name
*/
struct ast_channel *ast_channel_get_by_exten(const char *exten, const char *context);
/*!
* \brief Find a channel by a uniqueid
*
* \param uniqueid The uniqueid to search for
*
* \retval a channel with the uniqueid specified by the arguments
* \retval NULL if no channel was found
*/
struct ast_channel *ast_channel_get_by_uniqueid(const char *uniqueid);
/*! @} End channel search functions. */
/*!
@@ -5084,5 +5112,27 @@ void *ast_channel_get_stream_topology_change_source(struct ast_channel *chan);
#define ast_channel_has_tech_function(chan, function) \
(ast_channel_tech(chan) ? ast_channel_tech(chan)->function != NULL : 0)
/*!
* \brief Get the name of the current channel storage driver
*
* \return The name of the current channel storage driver
*/
const char *ast_channel_get_current_storage_driver_name(void);
/*!
* \internal
* \brief Set the current channel storage driver
*
* \param driver_name The name of the driver to set as the current driver
*
* \return 0 on success, -1 on failure
*
* \warning Changing the channel storage driver while Asterisk is running is
* not supported. This function will return an error if called while
* the ast_fully_booted flag is set. The function is exposed only
* because options.c needs it to set the driver when reading
* asterisk.conf.
*/
int internal_channel_set_current_storage_driver(const char *driver_name);
#endif /* _ASTERISK_CHANNEL_H */

View File

@@ -39,4 +39,11 @@ void ast_channel_internal_set_stream_topology_change_source(
void ast_channel_internal_swap_stream_topology(struct ast_channel *chan1,
struct ast_channel *chan2);
/*! \brief The current channel storage driver */
extern const struct ast_channelstorage_driver *current_channel_storage_driver;
extern struct ast_channelstorage_instance *current_channel_storage_instance;
void ast_channel_close_storage(void);
int ast_channel_open_storage(void);
#endif /* ASTERISK_CHANNEL_INTERNAL_H */

View File

@@ -32,6 +32,7 @@ extern "C" {
#define AST_CACHE_DIR_LEN 512
#define AST_FILENAME_MAX 80
#define AST_CHANNEL_NAME 80 /*!< Max length of an ast_channel name */
#define AST_CHANNEL_STORAGE_BACKEND_NAME_LEN 80 /*!< Max length of storage backend name */
/*! \ingroup main_options */