summaryrefslogtreecommitdiff
path: root/main/threadpool.c
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2014-09-29 20:28:24 +0000
committerRichard Mudgett <rmudgett@digium.com>2014-09-29 20:28:24 +0000
commit9d2bc0675a6de60ea6df50a6becaa0b4f84bba93 (patch)
treefbb913f8f299d628fd34724336544fc1cabfcd1e /main/threadpool.c
parent2eef53c465460609cd66770b5dcdcb17a20fc33e (diff)
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 ........ Merged revisions 424097 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@424098 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/threadpool.c')
-rw-r--r--main/threadpool.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/main/threadpool.c b/main/threadpool.c
index 6cb241bcf..597e83e10 100644
--- a/main/threadpool.c
+++ b/main/threadpool.c
@@ -385,13 +385,15 @@ static void threadpool_destructor(void *obj)
* \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)
+static struct ast_threadpool *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);
+ RAII_VAR(struct ast_threadpool *, pool, NULL, ao2_cleanup);
+ struct ast_str *control_tps_name;
- if (!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_threadpool *ast_threadpool_create(const char *name,
{
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 void serializer_dtor(void *obj)
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;
}