[Asterisk-code-review] Revert "stasis cache: Stop caching stasis subscription chan... (asterisk[16])

George Joseph asteriskteam at digium.com
Wed Dec 26 10:25:00 CST 2018


Hello Richard Mudgett, Friendly Automation, Sean Bright, Joshua C. Colp,

I'd like you to do a code review. Please visit

    https://gerrit.asterisk.org/10835

to review the following change.


Change subject: Revert "stasis_cache:  Stop caching stasis subscription change messages"
......................................................................

Revert "stasis_cache:  Stop caching stasis subscription change messages"

This commit caused issues with polling when combined with
the revert commit "Revert "app_voicemail: Remove need to subscribe to stasis"

This reverts commit 17d6d9e1e7d0db04ebd8d2e0cd9e087ec5462e2f.

ASTERISK-28222
Reported by: abelbeck

Change-Id: Ib6a16cbe2c0b74c76c64264f525ab647959c1483
---
M main/stasis_cache.c
1 file changed, 22 insertions(+), 9 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/35/10835/1

diff --git a/main/stasis_cache.c b/main/stasis_cache.c
index acf6fd0..9907c6c 100644
--- a/main/stasis_cache.c
+++ b/main/stasis_cache.c
@@ -817,16 +817,29 @@
 
 	msg_type = stasis_message_type(message);
 
-	/*
-	 * app_voicemail used to rely on the cache containing every topic subscribe and
-	 * unsubscribe in order to determine if anyone was currently subscribed to a
-	 * particular mailbox.  This caused the cache to grow unabated for the life of
-	 * the asterisk instance.  Since it no longer needs the cache of these message
-	 * types, and no other function needs them, we no longer cache them.
-	 */
 	if (stasis_subscription_change_type() == msg_type) {
-		ao2_cleanup(caching_topic_needs_unref);
-		return;
+		struct stasis_subscription_change *change = stasis_message_data(message);
+
+		/*
+		 * If this change type is an unsubscribe, we need to find the original
+		 * subscribe and remove it from the cache otherwise the cache will
+		 * continue to grow unabated.
+		 */
+		if (strcmp(change->description, "Unsubscribe") == 0) {
+			struct stasis_cache_entry *sub;
+
+			ao2_wrlock(caching_topic->cache->entries);
+			sub = cache_find(caching_topic->cache->entries, stasis_subscription_change_type(), change->uniqueid);
+			if (sub) {
+				cache_remove(caching_topic->cache->entries, sub, stasis_message_eid(message));
+				ao2_cleanup(sub);
+			}
+			ao2_unlock(caching_topic->cache->entries);
+			ao2_cleanup(caching_topic_needs_unref);
+			return;
+		}
+		msg_put = message;
+		msg = message;
 	} else if (stasis_cache_clear_type() == msg_type) {
 		/* Cache clear event. */
 		msg_put = NULL;

-- 
To view, visit https://gerrit.asterisk.org/10835
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib6a16cbe2c0b74c76c64264f525ab647959c1483
Gerrit-Change-Number: 10835
Gerrit-PatchSet: 1
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Friendly Automation (1000185)
Gerrit-Reviewer: Joshua C. Colp <jcolp at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Sean Bright <sean.bright at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20181226/1585d13a/attachment-0001.html>


More information about the asterisk-code-review mailing list