[asterisk-commits] dlee: trunk r393542 - in /trunk: configs/ include/asterisk/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jul 3 12:20:46 CDT 2013


Author: dlee
Date: Wed Jul  3 12:20:43 2013
New Revision: 393542

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=393542
Log:
Configuration for Stasis threadpool

The appropriate settings for the Stasis threadpool is very system
specific, depending upon both workload and system configuration.

This patch adds a stasis.conf file which can be used to configure the
key attributes of the threadpool for the Stasis message bus.

(closes issue ASTERISK-21280)
Review: https://reviewboard.asterisk.org/r/2651/

Added:
    trunk/configs/stasis.conf.sample
      - copied unchanged from r393538, team/dlee/stasis-config/configs/stasis.conf.sample
    trunk/main/stasis_config.c
      - copied unchanged from r393538, team/dlee/stasis-config/main/stasis_config.c
Removed:
    trunk/configs/stasis_core.conf.sample
Modified:
    trunk/include/asterisk/stasis.h
    trunk/main/asterisk.c
    trunk/main/stasis.c

Modified: trunk/include/asterisk/stasis.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/stasis.h?view=diff&rev=393542&r1=393541&r2=393542
==============================================================================
--- trunk/include/asterisk/stasis.h (original)
+++ trunk/include/asterisk/stasis.h Wed Jul  3 12:20:43 2013
@@ -809,15 +809,19 @@
 /*! @{ */
 
 /*!
- * \brief Initialize the Stasis subsystem
+ * \brief Initialize the Stasis subsystem.
  * \return 0 on success.
  * \return Non-zero on error.
  * \since 12
  */
 int stasis_init(void);
 
-/*!
- * \private
+/*! @} */
+
+/*! @{ */
+
+/*!
+ * \internal
  * \brief called by stasis_init() for cache initialization.
  * \return 0 on success.
  * \return Non-zero on error.
@@ -825,6 +829,25 @@
  */
 int stasis_cache_init(void);
 
+/*!
+ * \internal
+ * \brief called by stasis_init for config initialization.
+ * \return 0 on success.
+ * \return Non-zero on error.
+ * \since 12
+ */
+int stasis_config_init(void);
+
+struct ast_threadpool_options;
+
+/*!
+ * \internal
+ * \brief Retrieves the Stasis threadpool configuration.
+ * \param[out] threadpool_options Filled with Stasis threadpool options.
+ */
+void stasis_config_get_threadpool_options(
+	struct ast_threadpool_options *threadpool_options);
+
 /*! @} */
 
 /*!

Modified: trunk/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/asterisk.c?view=diff&rev=393542&r1=393541&r2=393542
==============================================================================
--- trunk/main/asterisk.c (original)
+++ trunk/main/asterisk.c Wed Jul  3 12:20:43 2013
@@ -4202,6 +4202,13 @@
 		exit(1);
 	}
 
+#ifdef AST_XML_DOCS
+	/* Load XML documentation. */
+	ast_xmldoc_load_documentation();
+#endif
+
+	aco_init();
+
 	if (stasis_init()) {
 		printf("Stasis initialization failed.\n%s", term_quit());
 		exit(1);
@@ -4261,13 +4268,6 @@
 		exit(1);
 	}
 
-#ifdef AST_XML_DOCS
-	/* Load XML documentation. */
-	ast_xmldoc_load_documentation();
-#endif
-
-	aco_init();
-
 	if (app_init()) {
 		printf("App core initialization failed.\n%s", term_quit());
 		exit(1);

Modified: trunk/main/stasis.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/stasis.c?view=diff&rev=393542&r1=393541&r2=393542
==============================================================================
--- trunk/main/stasis.c (original)
+++ trunk/main/stasis.c Wed Jul  3 12:20:43 2013
@@ -642,24 +642,25 @@
 {
 	int cache_init;
 
-	/* XXX Should this be configurable? */
-	struct ast_threadpool_options opts = {
-		.version = AST_THREADPOOL_OPTIONS_VERSION,
-		.idle_timeout = 20,
-		.auto_increment = 1,
-		.initial_size = 0,
-		.max_size = 200
-	};
+	struct ast_threadpool_options opts;
 
 	/* Be sure the types are cleaned up after the message bus */
 	ast_register_cleanup(stasis_cleanup);
 	ast_register_atexit(stasis_exit);
 
+	if (stasis_config_init() != 0) {
+		ast_log(LOG_ERROR, "Stasis configuration failed\n");
+		return -1;
+	}
+
 	if (pool) {
 		ast_log(LOG_ERROR, "Stasis double-initialized\n");
 		return -1;
 	}
 
+	stasis_config_get_threadpool_options(&opts);
+	ast_debug(3, "Creating Stasis threadpool: initial_size = %d, max_size = %d, idle_timeout_secs = %d\n",
+		opts.initial_size, opts.max_size, opts.idle_timeout);
 	pool = ast_threadpool_create("stasis-core", NULL, &opts);
 	if (!pool) {
 		ast_log(LOG_ERROR, "Stasis threadpool allocation failed\n");




More information about the asterisk-commits mailing list