From 33801137f8f9d518b84eb84b558dd41f9d9cea8d Mon Sep 17 00:00:00 2001 From: "Kevin P. Fleming" Date: Fri, 1 Apr 2005 21:38:17 +0000 Subject: don't take the channel list lock until we're actually ready to put the new channel into the list in ast_channel_alloc (bug #3928) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5352 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- channel.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'channel.c') diff --git a/channel.c b/channel.c index 460d1b781..0f73af1d7 100755 --- a/channel.c +++ b/channel.c @@ -322,11 +322,9 @@ struct ast_channel *ast_channel_alloc(int needqueue) if (shutting_down) return NULL; - ast_mutex_lock(&chlock); tmp = malloc(sizeof(struct ast_channel)); if (!tmp) { ast_log(LOG_WARNING, "Out of memory\n"); - ast_mutex_unlock(&chlock); return NULL; } @@ -335,7 +333,6 @@ struct ast_channel *ast_channel_alloc(int needqueue) if (!tmp->sched) { ast_log(LOG_WARNING, "Unable to create schedule context\n"); free(tmp); - ast_mutex_unlock(&chlock); return NULL; } @@ -359,7 +356,6 @@ struct ast_channel *ast_channel_alloc(int needqueue) if (pipe(tmp->alertpipe)) { ast_log(LOG_WARNING, "Alert pipe creation failed!\n"); free(tmp); - ast_mutex_unlock(&chlock); return NULL; } else { flags = fcntl(tmp->alertpipe[0], F_GETFL); @@ -396,6 +392,7 @@ struct ast_channel *ast_channel_alloc(int needqueue) tmp->tech = &null_tech; + ast_mutex_lock(&chlock); tmp->next = channels; channels = tmp; -- cgit v1.2.3