avoid hypothetical problem with flushing queue with delayed events

This commit is contained in:
Anthony Minessale 2010-11-08 15:04:51 -06:00
parent f53ce50a4c
commit 49b6237ed2
1 changed files with 9 additions and 2 deletions

View File

@ -790,10 +790,17 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_message(switch_core_
SWITCH_DECLARE(switch_status_t) switch_core_session_flush_message(switch_core_session_t *session)
{
switch_status_t status = SWITCH_STATUS_FALSE;
void *pop;
switch_core_session_message_t *message;
while (switch_core_session_dequeue_message(session, &message) == SWITCH_STATUS_SUCCESS) {
switch_core_session_free_message(&message);
switch_assert(session != NULL);
if (session->message_queue) {
while ((status = (switch_status_t) switch_queue_trypop(session->message_queue, &pop)) == SWITCH_STATUS_SUCCESS) {
message = (switch_core_session_message_t *) pop;
switch_core_session_free_message(&message);
}
}
return SWITCH_STATUS_SUCCESS;