summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/autoservice.c2
-rw-r--r--main/bridge_after.c2
-rw-r--r--main/bridge_channel.c2
-rw-r--r--main/channel.c39
-rw-r--r--main/file.c20
-rw-r--r--main/manager.c8
-rw-r--r--main/pbx.c4
-rw-r--r--main/pbx_builtins.c8
-rw-r--r--main/test.c4
9 files changed, 56 insertions, 33 deletions
diff --git a/main/autoservice.c b/main/autoservice.c
index 11c9eab96..d1a0156ab 100644
--- a/main/autoservice.c
+++ b/main/autoservice.c
@@ -295,11 +295,11 @@ int ast_autoservice_stop(struct ast_channel *chan)
res = 0;
}
+ ast_channel_lock(chan);
if (!as->orig_end_dtmf_flag) {
ast_clear_flag(ast_channel_flags(chan), AST_FLAG_END_DTMF_ONLY);
}
- ast_channel_lock(chan);
while ((f = AST_LIST_REMOVE_HEAD(&as->deferred_frames, frame_list))) {
if (!((1 << f->frametype) & as->ignore_frame_types)) {
ast_queue_frame_head(chan, f);
diff --git a/main/bridge_after.c b/main/bridge_after.c
index d649717e2..d4aec75d0 100644
--- a/main/bridge_after.c
+++ b/main/bridge_after.c
@@ -482,7 +482,7 @@ int ast_bridge_setup_after_goto(struct ast_channel *chan)
}
} else if (!ast_check_hangup(chan)) {
/* Clear the outgoing flag */
- ast_clear_flag(ast_channel_flags(chan), AST_FLAG_OUTGOING);
+ ast_channel_clear_flag(chan, AST_FLAG_OUTGOING);
if (after_bridge->specific) {
goto_failed = ast_explicit_goto(chan, after_bridge->context,
diff --git a/main/bridge_channel.c b/main/bridge_channel.c
index b299ca98f..02783b103 100644
--- a/main/bridge_channel.c
+++ b/main/bridge_channel.c
@@ -2106,7 +2106,7 @@ void bridge_channel_internal_pull(struct ast_bridge_channel *bridge_channel)
&& (ast_channel_is_leaving_bridge(bridge_channel->chan)
|| bridge_channel->state == BRIDGE_CHANNEL_STATE_WAIT)) {
ast_debug(2, "Channel %s will survive this bridge; clearing outgoing (dialed) flag\n", ast_channel_name(bridge_channel->chan));
- ast_clear_flag(ast_channel_flags(bridge_channel->chan), AST_FLAG_OUTGOING);
+ ast_channel_clear_flag(bridge_channel->chan, AST_FLAG_OUTGOING);
}
bridge->reconfigured = 1;
diff --git a/main/channel.c b/main/channel.c
index 099e6f65a..4451e524f 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -1288,8 +1288,10 @@ int ast_channel_defer_dtmf(struct ast_channel *chan)
int pre = 0;
if (chan) {
+ ast_channel_lock(chan);
pre = ast_test_flag(ast_channel_flags(chan), AST_FLAG_DEFER_DTMF);
ast_set_flag(ast_channel_flags(chan), AST_FLAG_DEFER_DTMF);
+ ast_channel_unlock(chan);
}
return pre;
}
@@ -1297,8 +1299,9 @@ int ast_channel_defer_dtmf(struct ast_channel *chan)
/*! \brief Unset defer DTMF flag on channel */
void ast_channel_undefer_dtmf(struct ast_channel *chan)
{
- if (chan)
- ast_clear_flag(ast_channel_flags(chan), AST_FLAG_DEFER_DTMF);
+ if (chan) {
+ ast_channel_clear_flag(chan, AST_FLAG_DEFER_DTMF);
+ }
}
struct ast_channel *ast_channel_callback(ao2_callback_data_fn *cb_fn, void *arg,
@@ -3223,7 +3226,7 @@ int ast_waitfordigit_full(struct ast_channel *c, int timeout_ms, int audiofd, in
return -1;
/* Only look for the end of DTMF, don't bother with the beginning and don't emulate things */
- ast_set_flag(ast_channel_flags(c), AST_FLAG_END_DTMF_ONLY);
+ ast_channel_set_flag(c, AST_FLAG_END_DTMF_ONLY);
/* Wait for a digit, no more than timeout_ms milliseconds total.
* Or, wait indefinitely if timeout_ms is <0.
@@ -3242,12 +3245,12 @@ int ast_waitfordigit_full(struct ast_channel *c, int timeout_ms, int audiofd, in
if (errno == 0 || errno == EINTR)
continue;
ast_log(LOG_WARNING, "Wait failed (%s)\n", strerror(errno));
- ast_clear_flag(ast_channel_flags(c), AST_FLAG_END_DTMF_ONLY);
+ ast_channel_clear_flag(c, AST_FLAG_END_DTMF_ONLY);
return -1;
} else if (outfd > -1) {
/* The FD we were watching has something waiting */
ast_log(LOG_WARNING, "The FD we were waiting for has something waiting. Waitfordigit returning numeric 1\n");
- ast_clear_flag(ast_channel_flags(c), AST_FLAG_END_DTMF_ONLY);
+ ast_channel_clear_flag(c, AST_FLAG_END_DTMF_ONLY);
return 1;
} else if (rchan) {
int res;
@@ -3261,13 +3264,13 @@ int ast_waitfordigit_full(struct ast_channel *c, int timeout_ms, int audiofd, in
case AST_FRAME_DTMF_END:
res = f->subclass.integer;
ast_frfree(f);
- ast_clear_flag(ast_channel_flags(c), AST_FLAG_END_DTMF_ONLY);
+ ast_channel_clear_flag(c, AST_FLAG_END_DTMF_ONLY);
return res;
case AST_FRAME_CONTROL:
switch (f->subclass.integer) {
case AST_CONTROL_HANGUP:
ast_frfree(f);
- ast_clear_flag(ast_channel_flags(c), AST_FLAG_END_DTMF_ONLY);
+ ast_channel_clear_flag(c, AST_FLAG_END_DTMF_ONLY);
return -1;
case AST_CONTROL_STREAM_STOP:
case AST_CONTROL_STREAM_SUSPEND:
@@ -3278,7 +3281,7 @@ int ast_waitfordigit_full(struct ast_channel *c, int timeout_ms, int audiofd, in
* that perform stream control will handle this. */
res = f->subclass.integer;
ast_frfree(f);
- ast_clear_flag(ast_channel_flags(c), AST_FLAG_END_DTMF_ONLY);
+ ast_channel_clear_flag(c, AST_FLAG_END_DTMF_ONLY);
return res;
case AST_CONTROL_PVT_CAUSE_CODE:
case AST_CONTROL_RINGING:
@@ -3313,7 +3316,7 @@ int ast_waitfordigit_full(struct ast_channel *c, int timeout_ms, int audiofd, in
}
}
- ast_clear_flag(ast_channel_flags(c), AST_FLAG_END_DTMF_ONLY);
+ ast_channel_clear_flag(c, AST_FLAG_END_DTMF_ONLY);
return 0; /* Time is up */
}
@@ -5709,9 +5712,9 @@ struct ast_channel *ast_call_forward(struct ast_channel *caller, struct ast_chan
} else if (caller) { /* no outgoing helper so use caller if available */
call_forward_inherit(new_chan, caller, orig);
}
- ast_set_flag(ast_channel_flags(new_chan), AST_FLAG_ORIGINATED);
ast_channel_lock_both(orig, new_chan);
+ ast_channel_set_flag(new_chan, AST_FLAG_ORIGINATED);
pbx_builtin_setvar_helper(new_chan, "FORWARDERNAME", forwarder);
ast_party_connected_line_copy(ast_channel_connected(new_chan), ast_channel_connected(orig));
ast_party_redirecting_copy(ast_channel_redirecting(new_chan), ast_channel_redirecting(orig));
@@ -9113,7 +9116,7 @@ static int redirecting_reason_build_data(unsigned char *data, size_t datalen,
if (reason->str) {
length = strlen(reason->str);
- if (datalen < pos + sizeof(data[0] * 2) + length) {
+ if (datalen < pos + (sizeof(data[0]) * 2) + length) {
ast_log(LOG_WARNING, "No space left for %s string\n", label);
return -1;
}
@@ -10947,3 +10950,17 @@ int ast_channel_stream_topology_changed(struct ast_channel *chan, struct ast_str
return ast_channel_tech(chan)->indicate(chan, AST_CONTROL_STREAM_TOPOLOGY_CHANGED, topology, sizeof(topology));
}
+
+void ast_channel_set_flag(struct ast_channel *chan, unsigned int flag)
+{
+ ast_channel_lock(chan);
+ ast_set_flag(ast_channel_flags(chan), flag);
+ ast_channel_unlock(chan);
+}
+
+void ast_channel_clear_flag(struct ast_channel *chan, unsigned int flag)
+{
+ ast_channel_lock(chan);
+ ast_clear_flag(ast_channel_flags(chan), flag);
+ ast_channel_unlock(chan);
+}
diff --git a/main/file.c b/main/file.c
index fb4ede6c8..41131f9ee 100644
--- a/main/file.c
+++ b/main/file.c
@@ -1543,7 +1543,7 @@ static int waitstream_core(struct ast_channel *c,
reverse = "";
/* Switch the channel to end DTMF frame only. waitstream_core doesn't care about the start of DTMF. */
- ast_set_flag(ast_channel_flags(c), AST_FLAG_END_DTMF_ONLY);
+ ast_channel_set_flag(c, AST_FLAG_END_DTMF_ONLY);
if (ast_test_flag(ast_channel_flags(c), AST_FLAG_MASQ_NOSTREAM))
orig_chan_name = ast_strdupa(ast_channel_name(c));
@@ -1575,7 +1575,7 @@ static int waitstream_core(struct ast_channel *c,
res = ast_waitfor(c, ms);
if (res < 0) {
ast_log(LOG_WARNING, "Select failed (%s)\n", strerror(errno));
- ast_clear_flag(ast_channel_flags(c), AST_FLAG_END_DTMF_ONLY);
+ ast_channel_clear_flag(c, AST_FLAG_END_DTMF_ONLY);
return res;
}
} else {
@@ -1586,11 +1586,11 @@ static int waitstream_core(struct ast_channel *c,
if (errno == EINTR)
continue;
ast_log(LOG_WARNING, "Wait failed (%s)\n", strerror(errno));
- ast_clear_flag(ast_channel_flags(c), AST_FLAG_END_DTMF_ONLY);
+ ast_channel_clear_flag(c, AST_FLAG_END_DTMF_ONLY);
return -1;
} else if (outfd > -1) { /* this requires cmdfd set */
/* The FD we were watching has something waiting */
- ast_clear_flag(ast_channel_flags(c), AST_FLAG_END_DTMF_ONLY);
+ ast_channel_clear_flag(c, AST_FLAG_END_DTMF_ONLY);
return 1;
}
/* if rchan is set, it is 'c' */
@@ -1599,7 +1599,7 @@ static int waitstream_core(struct ast_channel *c,
if (res > 0) {
struct ast_frame *fr = ast_read(c);
if (!fr) {
- ast_clear_flag(ast_channel_flags(c), AST_FLAG_END_DTMF_ONLY);
+ ast_channel_clear_flag(c, AST_FLAG_END_DTMF_ONLY);
return -1;
}
switch (fr->frametype) {
@@ -1610,7 +1610,7 @@ static int waitstream_core(struct ast_channel *c,
S_COR(ast_channel_caller(c)->id.number.valid, ast_channel_caller(c)->id.number.str, NULL))) {
res = fr->subclass.integer;
ast_frfree(fr);
- ast_clear_flag(ast_channel_flags(c), AST_FLAG_END_DTMF_ONLY);
+ ast_channel_clear_flag(c, AST_FLAG_END_DTMF_ONLY);
return res;
}
} else {
@@ -1626,7 +1626,7 @@ static int waitstream_core(struct ast_channel *c,
"Break");
ast_frfree(fr);
- ast_clear_flag(ast_channel_flags(c), AST_FLAG_END_DTMF_ONLY);
+ ast_channel_clear_flag(c, AST_FLAG_END_DTMF_ONLY);
return res;
}
}
@@ -1643,7 +1643,7 @@ static int waitstream_core(struct ast_channel *c,
"Break");
res = fr->subclass.integer;
ast_frfree(fr);
- ast_clear_flag(ast_channel_flags(c), AST_FLAG_END_DTMF_ONLY);
+ ast_channel_clear_flag(c, AST_FLAG_END_DTMF_ONLY);
return res;
case AST_CONTROL_STREAM_REVERSE:
if (!skip_ms) {
@@ -1661,7 +1661,7 @@ static int waitstream_core(struct ast_channel *c,
case AST_CONTROL_BUSY:
case AST_CONTROL_CONGESTION:
ast_frfree(fr);
- ast_clear_flag(ast_channel_flags(c), AST_FLAG_END_DTMF_ONLY);
+ ast_channel_clear_flag(c, AST_FLAG_END_DTMF_ONLY);
return -1;
case AST_CONTROL_RINGING:
case AST_CONTROL_ANSWER:
@@ -1698,7 +1698,7 @@ static int waitstream_core(struct ast_channel *c,
ast_sched_runq(ast_channel_sched(c));
}
- ast_clear_flag(ast_channel_flags(c), AST_FLAG_END_DTMF_ONLY);
+ ast_channel_clear_flag(c, AST_FLAG_END_DTMF_ONLY);
return (err || ast_channel_softhangup_internal_flag(c)) ? -1 : 0;
}
diff --git a/main/manager.c b/main/manager.c
index c592fbd37..1bbd1bbe9 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -4847,14 +4847,10 @@ static int action_redirect(struct mansession *s, const struct message *m)
/* Release the bridge wait. */
if (chan1_wait) {
- ast_channel_lock(chan);
- ast_clear_flag(ast_channel_flags(chan), AST_FLAG_BRIDGE_DUAL_REDIRECT_WAIT);
- ast_channel_unlock(chan);
+ ast_channel_clear_flag(chan, AST_FLAG_BRIDGE_DUAL_REDIRECT_WAIT);
}
if (chan2_wait) {
- ast_channel_lock(chan2);
- ast_clear_flag(ast_channel_flags(chan2), AST_FLAG_BRIDGE_DUAL_REDIRECT_WAIT);
- ast_channel_unlock(chan2);
+ ast_channel_clear_flag(chan2, AST_FLAG_BRIDGE_DUAL_REDIRECT_WAIT);
}
chan2 = ast_channel_unref(chan2);
diff --git a/main/pbx.c b/main/pbx.c
index 28027c06b..ccfba054e 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -4300,8 +4300,10 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
ast_channel_pbx(c)->rtimeoutms = 10000;
ast_channel_pbx(c)->dtimeoutms = 5000;
+ ast_channel_lock(c);
autoloopflag = ast_test_flag(ast_channel_flags(c), AST_FLAG_IN_AUTOLOOP); /* save value to restore at the end */
ast_set_flag(ast_channel_flags(c), AST_FLAG_IN_AUTOLOOP);
+ ast_channel_unlock(c);
if (ast_strlen_zero(ast_channel_exten(c))) {
/* If not successful fall back to 's' - but only if there is no given exten */
@@ -4546,8 +4548,10 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
ast_pbx_hangup_handler_run(c);
}
+ ast_channel_lock(c);
ast_set2_flag(ast_channel_flags(c), autoloopflag, AST_FLAG_IN_AUTOLOOP);
ast_clear_flag(ast_channel_flags(c), AST_FLAG_BRIDGE_HANGUP_RUN); /* from one round to the next, make sure this gets cleared */
+ ast_channel_unlock(c);
pbx_destroy(ast_channel_pbx(c));
ast_channel_pbx_set(c, NULL);
diff --git a/main/pbx_builtins.c b/main/pbx_builtins.c
index 20fdb4c22..bc27b0d58 100644
--- a/main/pbx_builtins.c
+++ b/main/pbx_builtins.c
@@ -1111,6 +1111,13 @@ static int pbx_builtin_background(struct ast_channel *chan, const char *data)
}
}
+ /* If ast_waitstream didn't give us back a digit, there is nothing else to do */
+ if (res <= 0) {
+ goto done;
+ }
+
+ exten[0] = res;
+
/*
* If the single digit DTMF is an extension in the specified context, then
* go there and signal no DTMF. Otherwise, we should exit with that DTMF.
@@ -1130,7 +1137,6 @@ static int pbx_builtin_background(struct ast_channel *chan, const char *data)
* be returned (see #16434).
*/
if (!ast_test_flag(ast_channel_flags(chan), AST_FLAG_DISABLE_WORKAROUNDS)
- && (exten[0] = res)
&& ast_canmatch_extension(chan, args.context, exten, 1,
S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))
&& !ast_matchmore_extension(chan, args.context, exten, 1,
diff --git a/main/test.c b/main/test.c
index 062451fb6..f45ad9b62 100644
--- a/main/test.c
+++ b/main/test.c
@@ -344,7 +344,7 @@ static int test_execute_multiple(const char *name, const char *category, struct
execute = 0;
switch (mode) {
case TEST_CATEGORY:
- if (!test_cat_cmp(test->info.category, category)) {
+ if (!test_cat_cmp(test->info.category, category) && !test->info.explicit_only) {
execute = 1;
}
break;
@@ -354,7 +354,7 @@ static int test_execute_multiple(const char *name, const char *category, struct
}
break;
case TEST_ALL:
- execute = 1;
+ execute = !test->info.explicit_only;
}
if (execute) {