[Asterisk-code-review] Stasis: Create human friendly taskprocessor/serializer names. (asterisk[master])

Richard Mudgett asteriskteam at digium.com
Fri Jan 8 14:08:22 CST 2016


Richard Mudgett has uploaded a new change for review.

  https://gerrit.asterisk.org/1956

Change subject: Stasis: Create human friendly taskprocessor/serializer names.
......................................................................

Stasis: Create human friendly taskprocessor/serializer names.

Stasis name formats:
subm:<topic>-<seq> -- Stasis subscription mailbox task processor
subp:<topic>-<seq> -- Stasis subscription thread pool serializer

Change-Id: Id19234b306e3594530bb040bc95d977f18ac7bfd
---
M main/stasis.c
1 file changed, 19 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/56/1956/1

diff --git a/main/stasis.c b/main/stasis.c
index fe940d3..0500569 100644
--- a/main/stasis.c
+++ b/main/stasis.c
@@ -462,22 +462,35 @@
 	}
 
 	/* The ao2 lock is used for join_cond. */
-	sub = ao2_t_alloc(sizeof(*sub), subscription_dtor, topic->name);
+	sub = ao2_t_alloc(sizeof(*sub), subscription_dtor, stasis_topic_name(topic));
 	if (!sub) {
 		return NULL;
 	}
 	ast_uuid_generate_str(sub->uniqueid, sizeof(sub->uniqueid));
 
 	if (needs_mailbox) {
-		/* With a small number of subscribers, a thread-per-sub is
-		 * acceptable. For larger number of subscribers, a thread
+		char tps_name[AST_TASKPROCESSOR_MAX_NAME + 1];
+		char seq[8 + 1 + 1];
+
+		/*
+		 * Create name with seq number appended.
+		 * Truncate topic name to ensure string fits.
+		 */
+		snprintf(seq, sizeof(seq), "-%08x", ast_taskprocessor_seq_num());
+		snprintf(tps_name, sizeof(tps_name) - sizeof(seq) + 1, "sub%c:%s",
+			use_thread_pool ? 'p' : 'm',
+			stasis_topic_name(topic));
+		strcat(tps_name, seq);
+
+		/*
+		 * With a small number of subscribers, a thread-per-sub is
+		 * acceptable. For a large number of subscribers, a thread
 		 * pool should be used.
 		 */
 		if (use_thread_pool) {
-			sub->mailbox = ast_threadpool_serializer(sub->uniqueid, pool);
+			sub->mailbox = ast_threadpool_serializer(tps_name, pool);
 		} else {
-			sub->mailbox = ast_taskprocessor_get(sub->uniqueid,
-				TPS_REF_DEFAULT);
+			sub->mailbox = ast_taskprocessor_get(tps_name, TPS_REF_DEFAULT);
 		}
 		if (!sub->mailbox) {
 			return NULL;

-- 
To view, visit https://gerrit.asterisk.org/1956
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id19234b306e3594530bb040bc95d977f18ac7bfd
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>



More information about the asterisk-code-review mailing list