aboutsummaryrefslogtreecommitdiffstats
path: root/channels/chan_local.c
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2009-03-16 17:38:50 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2009-03-16 17:38:50 +0000
commit66106444e580e020ac1590435df7a09699caef4a (patch)
treed99c0dadaf8cad8875abca2af0fafc2c5be62761 /channels/chan_local.c
parentba78c1a523431f09a9008e3e4640021348268527 (diff)
Merged revisions 182211,182278 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ................ r182211 | tilghman | 2009-03-16 10:50:55 -0500 (Mon, 16 Mar 2009) | 14 lines Merged revisions 182208 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r182208 | tilghman | 2009-03-16 10:39:15 -0500 (Mon, 16 Mar 2009) | 7 lines Fixup glare detection, to fix a memory leak of a local pvt structure. (closes issue #14656) Reported by: caspy Patches: 20090313__bug14656__2.diff.txt uploaded by tilghman (license 14) Tested by: caspy ........ ................ r182278 | tilghman | 2009-03-16 12:33:38 -0500 (Mon, 16 Mar 2009) | 7 lines Fix an off-by-one error in the FILE() function, and extend FILE()'s length parameter to work like variable substitution. Previously, FILE() returned one less character than specified, due to the terminating NULL. Both the offset and length parameters now behave identically to the way variable substitution offsets and lengths also work. (closes issue #14670) Reported by: BMC ................ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.1@182280 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_local.c')
-rw-r--r--channels/chan_local.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/channels/chan_local.c b/channels/chan_local.c
index a9a27ff8c..936264d21 100644
--- a/channels/chan_local.c
+++ b/channels/chan_local.c
@@ -203,23 +203,17 @@ static int local_queue_frame(struct local_pvt *p, int isoutbound, struct ast_fra
/* Recalculate outbound channel */
other = isoutbound ? p->owner : p->chan;
- /* Set glare detection */
- ast_set_flag(p, LOCAL_GLARE_DETECT);
- if (ast_test_flag(p, LOCAL_CANCEL_QUEUE)) {
- /* We had a glare on the hangup. Forget all this business,
- return and destroy p. */
- ast_mutex_unlock(&p->lock);
- p = local_pvt_destroy(p);
- return -1;
- }
if (!other) {
- ast_clear_flag(p, LOCAL_GLARE_DETECT);
return 0;
}
/* do not queue frame if generator is on both local channels */
- if (us && us->generator && other->generator)
+ if (us && us->generator && other->generator) {
return 0;
+ }
+
+ /* Set glare detection */
+ ast_set_flag(p, LOCAL_GLARE_DETECT);
/* Ensure that we have both channels locked */
while (other && ast_channel_trylock(other)) {
@@ -235,6 +229,17 @@ static int local_queue_frame(struct local_pvt *p, int isoutbound, struct ast_fra
other = isoutbound ? p->owner : p->chan;
}
+ /* Since glare detection only occurs within this function, and because
+ * a pvt flag cannot be set without having the pvt lock, this is the only
+ * location where we could detect a cancelling of the queue. */
+ if (ast_test_flag(p, LOCAL_CANCEL_QUEUE)) {
+ /* We had a glare on the hangup. Forget all this business,
+ return and destroy p. */
+ ast_mutex_unlock(&p->lock);
+ p = local_pvt_destroy(p);
+ return -1;
+ }
+
if (other) {
ast_queue_frame(other, f);
ast_channel_unlock(other);