]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-11407: [freeswitch-core] process media bugs in the order they were added #resolve
authorAnthony Minessale <anthm@freeswitch.org>
Sun, 23 Sep 2018 16:58:51 +0000 (16:58 +0000)
committerMike Jerris <mike@jerris.com>
Mon, 24 Sep 2018 17:38:50 +0000 (17:38 +0000)
src/switch_core_media_bug.c

index 49ed61cd61e7bf6f770dcf0977f7e5eb7f766d02..2a473d0c3d966db931f90fd06933cc97c7ff450e 100644 (file)
@@ -800,7 +800,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_add(switch_core_session_t
        switch_media_bug_t *bug, *bp;
        switch_size_t bytes;
        switch_event_t *event;
-       int tap_only = 1, punt = 0;
+       int tap_only = 1, punt = 0, added = 0;
 
        const char *p;
 
@@ -961,13 +961,21 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_add(switch_core_session_t
 
        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Attaching BUG to %s\n", switch_channel_get_name(session->channel));
        switch_thread_rwlock_wrlock(session->bug_rwlock);
-       bug->next = session->bugs;
-       session->bugs = bug;
 
+       if (!session->bugs) {
+               session->bugs = bug;
+               added = 1;
+       }
+       
        for(bp = session->bugs; bp; bp = bp->next) {
                if (bp->ready && !switch_test_flag(bp, SMBF_TAP_NATIVE_READ) && !switch_test_flag(bp, SMBF_TAP_NATIVE_WRITE)) {
                        tap_only = 0;
                }
+
+               if (!added && !bp->next) {
+                       bp->next = bug;
+                       break;
+               }
        }
 
        switch_thread_rwlock_unlock(session->bug_rwlock);