Skip to content
Snippets Groups Projects
Commit 87492f6d authored by Tilghman Lesher's avatar Tilghman Lesher
Browse files

Merged revisions 90432 via svnmerge from

https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r90432 | tilghman | 2007-12-02 03:34:23 -0600 (Sun, 02 Dec 2007) | 7 lines

Clarify the return value on autoservice.  Specifically, if you started
autoservice and autoservice was already on, it would erroneously return an
error.
Reported by: adiemus
Patch by: dimas
(Closes issue #11433)

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@90433 65c4cc65-6c06-0410-ace0-fbb531ad65f3
parent 7bf4fc6c
No related branches found
No related tags found
No related merge requests found
...@@ -130,7 +130,7 @@ static void *autoservice_run(void *ign) ...@@ -130,7 +130,7 @@ static void *autoservice_run(void *ign)
int ast_autoservice_start(struct ast_channel *chan) int ast_autoservice_start(struct ast_channel *chan)
{ {
int res = -1; int res = 0;
struct asent *as; struct asent *as;
AST_RWLIST_WRLOCK(&aslist); AST_RWLIST_WRLOCK(&aslist);
...@@ -144,11 +144,16 @@ int ast_autoservice_start(struct ast_channel *chan) ...@@ -144,11 +144,16 @@ int ast_autoservice_start(struct ast_channel *chan)
} }
/* If not, start autoservice on channel */ /* If not, start autoservice on channel */
if (!as && (as = ast_calloc(1, sizeof(*as)))) { if (as) {
/* Entry extist, autoservice is already handling this channel */
} else if ((as = ast_calloc(1, sizeof(*as))) == NULL) {
/* Memory allocation failed */
res = -1;
} else {
/* New entry created */
as->chan = chan; as->chan = chan;
as->use_count = 1; as->use_count = 1;
AST_RWLIST_INSERT_HEAD(&aslist, as, list); AST_RWLIST_INSERT_HEAD(&aslist, as, list);
res = 0;
if (asthread == AST_PTHREADT_NULL) { /* need start the thread */ if (asthread == AST_PTHREADT_NULL) { /* need start the thread */
if (ast_pthread_create_background(&asthread, NULL, autoservice_run, NULL)) { if (ast_pthread_create_background(&asthread, NULL, autoservice_run, NULL)) {
ast_log(LOG_WARNING, "Unable to create autoservice thread :(\n"); ast_log(LOG_WARNING, "Unable to create autoservice thread :(\n");
...@@ -173,7 +178,7 @@ int ast_autoservice_stop(struct ast_channel *chan) ...@@ -173,7 +178,7 @@ int ast_autoservice_stop(struct ast_channel *chan)
struct asent *as; struct asent *as;
AST_LIST_HEAD_NOLOCK(, ast_frame) dtmf_frames; AST_LIST_HEAD_NOLOCK(, ast_frame) dtmf_frames;
struct ast_frame *f; struct ast_frame *f;
int removed = 1; int removed = 0;
AST_LIST_HEAD_INIT_NOLOCK(&dtmf_frames); AST_LIST_HEAD_INIT_NOLOCK(&dtmf_frames);
...@@ -182,12 +187,11 @@ int ast_autoservice_stop(struct ast_channel *chan) ...@@ -182,12 +187,11 @@ int ast_autoservice_stop(struct ast_channel *chan)
if (as->chan == chan) { if (as->chan == chan) {
AST_RWLIST_REMOVE_CURRENT(list); AST_RWLIST_REMOVE_CURRENT(list);
as->use_count--; as->use_count--;
if (as->use_count) { if (as->use_count)
removed = 0;
break; break;
}
AST_LIST_APPEND_LIST(&dtmf_frames, &as->dtmf_frames, frame_list); AST_LIST_APPEND_LIST(&dtmf_frames, &as->dtmf_frames, frame_list);
ast_free(as); ast_free(as);
removed = 1;
if (!ast_check_hangup(chan)) if (!ast_check_hangup(chan))
res = 0; res = 0;
break; break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment