[Asterisk-code-review] stasis/endpoint: Fix memory leak of channel ids in ast endpo... (asterisk[16])
Friendly Automation
asteriskteam at digium.com
Mon Jan 14 08:26:54 CST 2019
Friendly Automation has submitted this change and it was merged. ( https://gerrit.asterisk.org/10862 )
Change subject: stasis/endpoint: Fix memory leak of channel_ids in ast_endpoint structure.
......................................................................
stasis/endpoint: Fix memory leak of channel_ids in ast_endpoint structure.
During Bridging of two channels if masquerade operation is performed on a
channel (clone channel) which was created with endpoint details
(ast_channel_alloc_with_endpoint()) and the original channel which is created
without endpoint details (ast_channel_alloc()) then both the channels must
exchange their endpoint details or else after masquerade when clone channel
is being destroyed the endpoint cleanup callbacks will be destroyed too and
after call completion unique_id of original channel will still be there in
ast_endpoint structure's channel_ids container.
ASTERISK-28197
Change-Id: Ied0451f378a3f2a36acc8c0984959a69895efa17
---
M include/asterisk/channel.h
M main/channel.c
M main/channel_internal_api.c
3 files changed, 30 insertions(+), 0 deletions(-)
Approvals:
Joshua C. Colp: Looks good to me, but someone else must approve
Corey Farrell: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved
Friendly Automation: Approved for Submit
diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h
index 3f22cdd..7a5a4ef 100644
--- a/include/asterisk/channel.h
+++ b/include/asterisk/channel.h
@@ -2650,6 +2650,18 @@
void ast_channel_internal_swap_topics(struct ast_channel *a, struct ast_channel *b);
/*!
+ * \brief Swap endpoint_forward and endpoint_cache_forward between two channels
+ * \param a First channel
+ * \param b Second channel
+ * \return void
+ *
+ * \note
+ * This is used in masquerade to exchange endpoint details if one of the two or both
+ * the channels were created with endpoint
+ */
+void ast_channel_internal_swap_endpoint_forward_and_endpoint_cache_forward(struct ast_channel *a, struct ast_channel *b);
+
+/*!
* \brief Set uniqueid and linkedid string value only (not time)
* \param chan The channel to set the uniqueid to
* \param uniqueid The uniqueid to set
diff --git a/main/channel.c b/main/channel.c
index 6c6e9f7..8f27822 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -6819,6 +6819,12 @@
/* Make sure the Stasis topic on the channel is updated appropriately */
ast_channel_internal_swap_topics(clonechan, original);
+ /* Swap endpoint forward and endpoint cache forward details of the channels,
+ * so channel created with endpoint exchanges its state with other channel
+ * for proper endpoint cleanup.
+ */
+ ast_channel_internal_swap_endpoint_forward_and_endpoint_cache_forward(clonechan, original);
+
/* Swap channel names. This uses ast_channel_name_set directly, so we
* don't get any spurious rename events.
*/
diff --git a/main/channel_internal_api.c b/main/channel_internal_api.c
index a963a7d..5269715 100644
--- a/main/channel_internal_api.c
+++ b/main/channel_internal_api.c
@@ -1388,6 +1388,18 @@
b->topics = temp;
}
+void ast_channel_internal_swap_endpoint_forward_and_endpoint_cache_forward(struct ast_channel *a, struct ast_channel *b)
+{
+ struct stasis_forward *temp;
+ temp = a->endpoint_forward;
+ a->endpoint_forward = b->endpoint_forward;
+ b->endpoint_forward = temp;
+
+ temp = a->endpoint_cache_forward;
+ a->endpoint_cache_forward = b->endpoint_cache_forward;
+ b->endpoint_cache_forward = temp;
+}
+
void ast_channel_internal_set_fake_ids(struct ast_channel *chan, const char *uniqueid, const char *linkedid)
{
ast_copy_string(chan->uniqueid.unique_id, uniqueid, sizeof(chan->uniqueid.unique_id));
--
To view, visit https://gerrit.asterisk.org/10862
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-MessageType: merged
Gerrit-Change-Id: Ied0451f378a3f2a36acc8c0984959a69895efa17
Gerrit-Change-Number: 10862
Gerrit-PatchSet: 2
Gerrit-Owner: Mohit Dhiman <mohitdhiman at drishti-soft.com>
Gerrit-Reviewer: Chris Savinovich <csavinovich at digium.com>
Gerrit-Reviewer: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Friendly Automation (1000185)
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua C. Colp <jcolp at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190114/d15f1183/attachment.html>
More information about the asterisk-code-review
mailing list