[asterisk-commits] rmudgett: branch 13 r424097 - in /branches/13: ./ main/threadpool.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Sep 29 15:26:52 CDT 2014


Author: rmudgett
Date: Mon Sep 29 15:26:50 2014
New Revision: 424097

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=424097
Log:
threadpool.c: Minor cleanup fixes.

* Fix threadpool_alloc() prototype.

* Add missing off-nominal NULL check of pool in threadpool_alloc().

* searializer_create() does not need to create the object with a lock as
the lock is not used.
........

Merged revisions 424096 from http://svn.asterisk.org/svn/asterisk/branches/12

Modified:
    branches/13/   (props changed)
    branches/13/main/threadpool.c

Propchange: branches/13/
------------------------------------------------------------------------------
Binary property 'branch-12-merged' - no diff available.

Modified: branches/13/main/threadpool.c
URL: http://svnview.digium.com/svn/asterisk/branches/13/main/threadpool.c?view=diff&rev=424097&r1=424096&r2=424097
==============================================================================
--- branches/13/main/threadpool.c (original)
+++ branches/13/main/threadpool.c Mon Sep 29 15:26:50 2014
@@ -385,13 +385,15 @@
  * \retval NULL Could not initialize threadpool properly
  * \retval non-NULL The newly-allocated threadpool
  */
-static void *threadpool_alloc(const char *name, const struct ast_threadpool_options *options)
-{
-	RAII_VAR(struct ast_threadpool *, pool,
-			ao2_alloc(sizeof(*pool), threadpool_destructor), ao2_cleanup);
-	struct ast_str *control_tps_name = ast_str_create(64);
-
-	if (!control_tps_name) {
+static struct ast_threadpool *threadpool_alloc(const char *name, const struct ast_threadpool_options *options)
+{
+	RAII_VAR(struct ast_threadpool *, pool, NULL, ao2_cleanup);
+	struct ast_str *control_tps_name;
+
+	pool = ao2_alloc(sizeof(*pool), threadpool_destructor);
+	control_tps_name = ast_str_create(64);
+	if (!pool || !control_tps_name) {
+		ast_free(control_tps_name);
 		return NULL;
 	}
 
@@ -859,8 +861,9 @@
 {
 	struct ast_taskprocessor *tps;
 	RAII_VAR(struct ast_taskprocessor_listener *, tps_listener, NULL, ao2_cleanup);
-	RAII_VAR(struct ast_threadpool *, pool, threadpool_alloc(name, options), ao2_cleanup);
-
+	RAII_VAR(struct ast_threadpool *, pool, NULL, ao2_cleanup);
+
+	pool = threadpool_alloc(name, options);
 	if (!pool) {
 		return NULL;
 	}
@@ -1136,7 +1139,9 @@
 
 static struct serializer *serializer_create(struct ast_threadpool *pool)
 {
-	struct serializer *ser = ao2_alloc(sizeof(*ser), serializer_dtor);
+	struct serializer *ser;
+
+	ser = ao2_alloc_options(sizeof(*ser), serializer_dtor, AO2_ALLOC_OPT_LOCK_NOLOCK);
 	if (!ser) {
 		return NULL;
 	}




More information about the asterisk-commits mailing list