]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Message.c: Clear message channel frames on cleanup 71/471/1
authorJonathan Rose <jrose@digium.com>
Wed, 13 May 2015 20:41:07 +0000 (15:41 -0500)
committerJonathan Rose <jrose@digium.com>
Thu, 14 May 2015 16:25:09 +0000 (11:25 -0500)
The message channel is a special channel that doesn't actually process frames.
However, certain actions can cause frames to be placed in the channel's read
queue including the Hangup application which is called on the channel after
each message is processed. Since the channel will continually be reused for
many messages, it's necessary to flush these frames at some point.

ASTERISK-25083 #close
Reported by: Jonathan Rose

Change-Id: Idf18df73ccd8c220be38743335b5c79c2a4c0d0f

main/message.c

index 64cefcb1b5fa30fa6a5c7d51dbdd14f210b551fa..7098f698d0e97a6fd7f23f3322a87a3a0833740d 100644 (file)
@@ -743,6 +743,7 @@ static void chan_cleanup(struct ast_channel *chan)
        struct ast_datastore *msg_ds, *ds;
        struct varshead *headp;
        struct ast_var_t *vardata;
+       struct ast_frame *cur;
 
        ast_channel_lock(chan);
 
@@ -771,6 +772,13 @@ static void chan_cleanup(struct ast_channel *chan)
                ast_var_delete(vardata);
        }
 
+       /*
+        * Remove frames from read queue
+        */
+       while ((cur = AST_LIST_REMOVE_HEAD(ast_channel_readq(chan), frame_list))) {
+               ast_frfree(cur);
+       }
+
        /*
         * Restore msg datastore.
         */