]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
avoid hypothetical problem with flushing queue with delayed events
authorAnthony Minessale <anthm@freeswitch.org>
Mon, 8 Nov 2010 21:04:51 +0000 (15:04 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Mon, 8 Nov 2010 21:05:02 +0000 (15:05 -0600)
src/switch_core_session.c

index 1589bebb672e6e88a3890c26424260092ec0ea46..b3bb638c76b18f07e323693517c3a3315b0f6354 100644 (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;