Index: main/rtp_engine.c =================================================================== --- main/rtp_engine.c (revision 306862) +++ main/rtp_engine.c (working copy) @@ -1022,13 +1022,19 @@ for (;;) { /* Check if anything changed */ if ((c0->tech_pvt != pvt0) || - (c1->tech_pvt != pvt1) || - (c0->masq || c0->masqr || c1->masq || c1->masqr) || - (c0->monitor || c0->audiohooks || c1->monitor || c1->audiohooks)) { - ast_debug(1, "Oooh, something is weird, backing out\n"); + (c0->masq || c0->masqr) || + (c0->monitor || c0->audiohooks )) { + ast_debug(1, "Oooh, something is weird on c0, backing out \n"); res = AST_BRIDGE_RETRY; break; } + if ((c1->tech_pvt != pvt1) || + (c1->masq || c1->masqr) || + (c1->monitor || c1->audiohooks)) { + ast_debug(1, "Oooh, something is weird on c1, backing out\n"); + res = AST_BRIDGE_RETRY; + break; + } /* Check if they have changed their address */ ast_rtp_instance_get_remote_address(instance1, &t1); @@ -1075,6 +1081,7 @@ ast_debug(1, "Oooh, '%s' was %s/(format %s)\n", c1->name, ast_sockaddr_stringify(&tac1), ast_getformatname(oldcodec1)); + ast_channel_lock(c0); if (glue0->update_peer(c0, ast_sockaddr_isnull(&t1) ? NULL : instance1, ast_sockaddr_isnull(&vt1) ? NULL : vinstance1, @@ -1082,6 +1089,7 @@ codec1, 0)) { ast_log(LOG_WARNING, "Channel '%s' failed to update to '%s'\n", c0->name, c1->name); } + ast_channel_unlock(c0); ast_sockaddr_copy(&ac1, &t1); ast_sockaddr_copy(&vac1, &vt1); ast_sockaddr_copy(&tac1, &tt1); @@ -1097,12 +1105,14 @@ ast_debug(1, "Oooh, '%s' was %s/(format %s)\n", c0->name, ast_sockaddr_stringify(&ac0), ast_getformatname(oldcodec0)); + ast_channel_lock(c1); if (glue1->update_peer(c1, t0.len ? instance0 : NULL, vt0.len ? vinstance0 : NULL, tt0.len ? tinstance0 : NULL, codec0, 0)) { ast_log(LOG_WARNING, "Channel '%s' failed to update to '%s'\n", c1->name, c0->name); } + ast_channel_unlock(c1); ast_sockaddr_copy(&ac0, &t0); ast_sockaddr_copy(&vac0, &vt0); ast_sockaddr_copy(&tac0, &tt0); @@ -1141,16 +1151,24 @@ if (fr->subclass.integer == AST_CONTROL_HOLD) { /* If we someone went on hold we want the other side to reinvite back to us */ if (who == c0) { + ast_channel_lock(c1); glue1->update_peer(c1, NULL, NULL, NULL, 0, 0); + ast_channel_unlock(c1); } else { + ast_channel_lock(c0); glue0->update_peer(c0, NULL, NULL, NULL, 0, 0); + ast_channel_unlock(c0); } } else if (fr->subclass.integer == AST_CONTROL_UNHOLD) { /* If they went off hold they should go back to being direct */ if (who == c0) { + ast_channel_lock(c1); glue1->update_peer(c1, instance0, vinstance0, tinstance0, codec0, 0); + ast_channel_unlock(c1); } else { + ast_channel_lock(c0); glue0->update_peer(c0, instance1, vinstance1, tinstance1, codec1, 0); + ast_channel_unlock(c0); } } /* Update local address information */ @@ -1202,12 +1220,17 @@ cs[1] = cs[2]; } + ast_channel_lock(c0); if (glue0->update_peer(c0, NULL, NULL, NULL, 0, 0)) { ast_log(LOG_WARNING, "Channel '%s' failed to break RTP bridge\n", c0->name); } + ast_channel_unlock(c0); + + ast_channel_lock(c1); if (glue1->update_peer(c1, NULL, NULL, NULL, 0, 0)) { ast_log(LOG_WARNING, "Channel '%s' failed to break RTP bridge\n", c1->name); } + ast_channel_unlock(c1); instance0->bridged = NULL; instance1->bridged = NULL;