[Asterisk-code-review] stasis: Fix ABI between DEVMODE and non-DEVMODE. (asterisk[16])

Friendly Automation asteriskteam at digium.com
Thu Jan 3 17:39:20 CST 2019


Friendly Automation has submitted this change and it was merged. ( https://gerrit.asterisk.org/10841 )

Change subject: stasis: Fix ABI between DEVMODE and non-DEVMODE.
......................................................................

stasis: Fix ABI between DEVMODE and non-DEVMODE.

Create compatibility stubs for maximum ABI compatibility.

ASTERISK-28212 #close

Change-Id: I872c04842ab6b61e9dd6d37e4166bc619aa20626
---
M include/asterisk/stasis.h
M include/asterisk/stasis_internal.h
M include/asterisk/stasis_message_router.h
M main/stasis.c
M main/stasis_cache.c
M main/stasis_message_router.c
6 files changed, 55 insertions(+), 77 deletions(-)

Approvals:
  Joshua C. Colp: Looks good to me, but someone else must approve
  Matthew Fredrickson: Looks good to me, approved
  Friendly Automation: Approved for Submit



diff --git a/include/asterisk/stasis.h b/include/asterisk/stasis.h
index 2e274a6..357f34e 100644
--- a/include/asterisk/stasis.h
+++ b/include/asterisk/stasis.h
@@ -604,9 +604,9 @@
  * has been subscribed. This occurs immediately before accepted message
  * types can be set and the callback must expect to receive it.
  */
-#ifdef AST_DEVMODE
 struct stasis_subscription *__stasis_subscribe(struct stasis_topic *topic,
 	stasis_subscription_cb callback, void *data, const char *file, int lineno, const char *func);
+#ifdef AST_DEVMODE
 #define stasis_subscribe(topic, callback, data) __stasis_subscribe(topic, callback, data, __FILE__, __LINE__, __PRETTY_FUNCTION__)
 #else
 struct stasis_subscription *stasis_subscribe(struct stasis_topic *topic,
@@ -639,9 +639,9 @@
  * has been subscribed. This occurs immediately before accepted message
  * types can be set and the callback must expect to receive it.
  */
-#ifdef AST_DEVMODE
 struct stasis_subscription *__stasis_subscribe_pool(struct stasis_topic *topic,
 	stasis_subscription_cb callback, void *data, const char *file, int lineno, const char *func);
+#ifdef AST_DEVMODE
 #define stasis_subscribe_pool(topic, callback, data) __stasis_subscribe_pool(topic, callback, data, __FILE__, __LINE__, __PRETTY_FUNCTION__)
 #else
 struct stasis_subscription *stasis_subscribe_pool(struct stasis_topic *topic,
diff --git a/include/asterisk/stasis_internal.h b/include/asterisk/stasis_internal.h
index c9df032..b3e56f1 100644
--- a/include/asterisk/stasis_internal.h
+++ b/include/asterisk/stasis_internal.h
@@ -60,7 +60,6 @@
  * \return \c NULL on error.
  * \since 12
  */
-#ifdef AST_DEVMODE
 struct stasis_subscription *internal_stasis_subscribe(
 	struct stasis_topic *topic,
 	stasis_subscription_cb callback,
@@ -70,13 +69,5 @@
 	const char *file,
 	int lineno,
 	const char *func);
-#else
-struct stasis_subscription *internal_stasis_subscribe(
-	struct stasis_topic *topic,
-	stasis_subscription_cb callback,
-	void *data,
-	int needs_mailbox,
-	int use_thread_pool);
-#endif
 
 #endif /* STASIS_INTERNAL_H_ */
diff --git a/include/asterisk/stasis_message_router.h b/include/asterisk/stasis_message_router.h
index 93a2140..fefbea0 100644
--- a/include/asterisk/stasis_message_router.h
+++ b/include/asterisk/stasis_message_router.h
@@ -55,9 +55,9 @@
  *
  * \since 12
  */
-#ifdef AST_DEVMODE
 struct stasis_message_router *__stasis_message_router_create(
 	struct stasis_topic *topic, const char *file, int lineno, const char *func);
+#ifdef AST_DEVMODE
 #define stasis_message_router_create(topic) __stasis_message_router_create(topic, __FILE__, __LINE__, __PRETTY_FUNCTION__)
 #else
 struct stasis_message_router *stasis_message_router_create(
@@ -77,9 +77,9 @@
  *
  * \since 12.8.0
  */
-#ifdef AST_DEVMODE
 struct stasis_message_router *__stasis_message_router_create_pool(
 	struct stasis_topic *topic, const char *file, int lineno, const char *func);
+#ifdef AST_DEVMODE
 #define stasis_message_router_create_pool(topic) __stasis_message_router_create_pool(topic, __FILE__, __LINE__, __PRETTY_FUNCTION__)
 #else
 struct stasis_message_router *stasis_message_router_create_pool(
diff --git a/main/stasis.c b/main/stasis.c
index 3216e21..b743f99 100644
--- a/main/stasis.c
+++ b/main/stasis.c
@@ -436,10 +436,11 @@
 	res |= AST_VECTOR_INIT(&topic->upstream_topics, 0);
 #ifdef AST_DEVMODE
 	topic->statistics = stasis_topic_statistics_create(name);
-	if (!topic->name || !topic->statistics || res) {
+	if (!topic->name || !topic->statistics || res)
 #else
-	if (!topic->name || res) {
+	if (!topic->name || res)
 #endif
+	{
 		ao2_ref(topic, -1);
 		return NULL;
 	}
@@ -640,7 +641,6 @@
 }
 #endif
 
-#ifdef AST_DEVMODE
 struct stasis_subscription *internal_stasis_subscribe(
 	struct stasis_topic *topic,
 	stasis_subscription_cb callback,
@@ -650,14 +650,6 @@
 	const char *file,
 	int lineno,
 	const char *func)
-#else
-struct stasis_subscription *internal_stasis_subscribe(
-	struct stasis_topic *topic,
-	stasis_subscription_cb callback,
-	void *data,
-	int needs_mailbox,
-	int use_thread_pool)
-#endif
 {
 	struct stasis_subscription *sub;
 
@@ -728,7 +720,6 @@
 	return sub;
 }
 
-#ifdef AST_DEVMODE
 struct stasis_subscription *__stasis_subscribe(
 	struct stasis_topic *topic,
 	stasis_subscription_cb callback,
@@ -739,17 +730,7 @@
 {
 	return internal_stasis_subscribe(topic, callback, data, 1, 0, file, lineno, func);
 }
-#else
-struct stasis_subscription *stasis_subscribe(
-	struct stasis_topic *topic,
-	stasis_subscription_cb callback,
-	void *data)
-{
-	return internal_stasis_subscribe(topic, callback, data, 1, 0);
-}
-#endif
 
-#ifdef AST_DEVMODE
 struct stasis_subscription *__stasis_subscribe_pool(
 	struct stasis_topic *topic,
 	stasis_subscription_cb callback,
@@ -760,15 +741,6 @@
 {
 	return internal_stasis_subscribe(topic, callback, data, 1, 1, file, lineno, func);
 }
-#else
-struct stasis_subscription *stasis_subscribe_pool(
-	struct stasis_topic *topic,
-	stasis_subscription_cb callback,
-	void *data)
-{
-	return internal_stasis_subscribe(topic, callback, data, 1, 1);
-}
-#endif
 
 static int sub_cleanup(void *data)
 {
@@ -2666,3 +2638,31 @@
 
 	return 0;
 }
+
+#ifdef AST_DEVMODE
+#undef stasis_subscribe
+struct stasis_subscription *stasis_subscribe(
+	struct stasis_topic *topic,
+	stasis_subscription_cb callback,
+	void *data);
+#undef stasis_subscribe_pool
+struct stasis_subscription *stasis_subscribe_pool(
+	struct stasis_topic *topic,
+	stasis_subscription_cb callback,
+	void *data);
+#endif
+struct stasis_subscription *stasis_subscribe(
+	struct stasis_topic *topic,
+	stasis_subscription_cb callback,
+	void *data)
+{
+	return internal_stasis_subscribe(topic, callback, data, 1, 0, __FILE__, __LINE__, __PRETTY_FUNCTION__);
+}
+
+struct stasis_subscription *stasis_subscribe_pool(
+	struct stasis_topic *topic,
+	stasis_subscription_cb callback,
+	void *data)
+{
+	return internal_stasis_subscribe(topic, callback, data, 1, 1, __FILE__, __LINE__, __PRETTY_FUNCTION__);
+}
diff --git a/main/stasis_cache.c b/main/stasis_cache.c
index 73a469e..ee8a1dd 100644
--- a/main/stasis_cache.c
+++ b/main/stasis_cache.c
@@ -984,11 +984,7 @@
 	}
 	ast_free(new_name);
 
-#ifdef AST_DEVMODE
 	caching_topic->sub = internal_stasis_subscribe(original_topic, caching_topic_exec, caching_topic, 0, 0, __FILE__, __LINE__, __PRETTY_FUNCTION__);
-#else
-	caching_topic->sub = internal_stasis_subscribe(original_topic, caching_topic_exec, caching_topic, 0, 0);
-#endif
 	if (caching_topic->sub == NULL) {
 		ao2_ref(caching_topic, -1);
 
diff --git a/main/stasis_message_router.c b/main/stasis_message_router.c
index 9a390ef..f320c34 100644
--- a/main/stasis_message_router.c
+++ b/main/stasis_message_router.c
@@ -204,14 +204,9 @@
 	}
 }
 
-#ifdef AST_DEVMODE
 static struct stasis_message_router *stasis_message_router_create_internal(
 	struct stasis_topic *topic, int use_thread_pool, const char *file, int lineno,
 	const char *func)
-#else
-static struct stasis_message_router *stasis_message_router_create_internal(
-	struct stasis_topic *topic, int use_thread_pool)
-#endif
 {
 	int res;
 	struct stasis_message_router *router;
@@ -230,19 +225,11 @@
 		return NULL;
 	}
 
-#ifdef AST_DEVMODE
 	if (use_thread_pool) {
 		router->subscription = __stasis_subscribe_pool(topic, router_dispatch, router, file, lineno, func);
 	} else {
 		router->subscription = __stasis_subscribe(topic, router_dispatch, router, file, lineno, func);
 	}
-#else
-	if (use_thread_pool) {
-		router->subscription = stasis_subscribe_pool(topic, router_dispatch, router);
-	} else {
-		router->subscription = stasis_subscribe(topic, router_dispatch, router);
-	}
-#endif
 
 	if (!router->subscription) {
 		ao2_ref(router, -1);
@@ -256,33 +243,17 @@
 	return router;
 }
 
-#ifdef AST_DEVMODE
 struct stasis_message_router *__stasis_message_router_create(
 	struct stasis_topic *topic, const char *file, int lineno, const char *func)
 {
 	return stasis_message_router_create_internal(topic, 0, file, lineno, func);
 }
-#else
-struct stasis_message_router *stasis_message_router_create(
-	struct stasis_topic *topic)
-{
-	return stasis_message_router_create_internal(topic, 0);
-}
-#endif
 
-#ifdef AST_DEVMODE
 struct stasis_message_router *__stasis_message_router_create_pool(
 	struct stasis_topic *topic, const char *file, int lineno, const char *func)
 {
 	return stasis_message_router_create_internal(topic, 1, file, lineno, func);
 }
-#else
-struct stasis_message_router *stasis_message_router_create_pool(
-	struct stasis_topic *topic)
-{
-	return stasis_message_router_create_internal(topic, 1);
-}
-#endif
 
 void stasis_message_router_unsubscribe(struct stasis_message_router *router)
 {
@@ -440,3 +411,23 @@
 
 	return;
 }
+
+#ifdef AST_DEVMODE
+#undef stasis_message_router_create
+struct stasis_message_router *stasis_message_router_create(
+	struct stasis_topic *topic);
+#undef stasis_message_router_create_pool
+struct stasis_message_router *stasis_message_router_create_pool(
+	struct stasis_topic *topic);
+#endif
+struct stasis_message_router *stasis_message_router_create(
+	struct stasis_topic *topic)
+{
+	return stasis_message_router_create_internal(topic, 0, __FILE__, __LINE__, __PRETTY_FUNCTION__);
+}
+
+struct stasis_message_router *stasis_message_router_create_pool(
+	struct stasis_topic *topic)
+{
+	return stasis_message_router_create_internal(topic, 1, __FILE__, __LINE__, __PRETTY_FUNCTION__);
+}

-- 
To view, visit https://gerrit.asterisk.org/10841
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: I872c04842ab6b61e9dd6d37e4166bc619aa20626
Gerrit-Change-Number: 10841
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Friendly Automation (1000185)
Gerrit-Reviewer: Joshua C. Colp <jcolp at digium.com>
Gerrit-Reviewer: Matthew Fredrickson <creslin at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190103/0ce53d42/attachment-0001.html>


More information about the asterisk-code-review mailing list