From: Anthony Minessale Date: Mon, 8 Nov 2010 21:04:51 +0000 (-0600) Subject: avoid hypothetical problem with flushing queue with delayed events X-Git-Tag: v1.2-rc1~265^2~11^2~42^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=49b6237ed2dc0b536ffd8114e0c5f233e133e3ff;p=thirdparty%2Ffreeswitch.git avoid hypothetical problem with flushing queue with delayed events --- diff --git a/src/switch_core_session.c b/src/switch_core_session.c index 1589bebb67..b3bb638c76 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -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;