Index: b/include/asterisk/channel.h
===================================================================
--- a/include/asterisk/channel.h
+++ b/include/asterisk/channel.h
@@ -4445,6 +4445,18 @@ int ast_channel_dialed_causes_add(const
  */
 void ast_channel_dialed_causes_clear(const struct ast_channel *chan);
 
+/*
+ * \brief Return the mutex associated to the global channels container.
+ *
+ * \details
+ * Note that the mutex is destroyed when the channels container is destroyed
+ * (during asterisk shutdown), but we have no way to safely get a reference to the
+ * channels container to make sure it isn't destroyed while we still have a reference
+ * on its mutex, so we ignore this whole situation completely and suppose the returned
+ * pointer is always valid.
+ */
+ast_mutex_t *ast_channels_get_mutex(void);
+
 struct ast_flags *ast_channel_flags(struct ast_channel *chan);
 
 /*!
Index: b/main/channel.c
===================================================================
--- a/main/channel.c
+++ b/main/channel.c
@@ -10981,6 +10981,12 @@ int ast_channel_feature_hooks_replace(st
 	return channel_feature_hooks_set_full(chan, features, 1);
 }
 
+
+ast_mutex_t *ast_channels_get_mutex(void)
+{
+	return ao2_object_get_lockaddr(channels);
+}
+
 enum ast_channel_error ast_channel_errno(void)
 {
 	return ast_channel_internal_errno();
