Bug 1564902 - Checked paused_ prior to calling SendPacket; r=bwc

There is a window inside of SendPacket where the critical section is released
which means that other code could set paused_. This would lead to us hitting
the assertion at the top of SendPacket. Checking paused_ in the while loop
will avoid this. Upstream has fixed this problem in a similar way, but the
code has changed there enough that it doesn't make sense to try to bring in
their fix directly.

Differential Revision: https://phabricator.services.mozilla.com/D48540

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Dan Minor 2019-10-08 15:42:58 +00:00
parent 73c11d0ebd
commit ad61673439

View File

@ -268,7 +268,11 @@ void PacedSender::Process() {
pacing_info = prober_->CurrentCluster();
recommended_probe_size = prober_->RecommendedMinProbeSize();
}
while (!packets_->Empty()) {
// We need to check paused_ here because the critical section protecting
// it is released during the call to SendPacket. This has been fixed in
// a similar way upstream, so these changes can be dropped the next time
// we update.
while (!paused_ && !packets_->Empty()) {
// Since we need to release the lock in order to send, we first pop the
// element from the priority queue but keep it in storage, so that we can
// reinsert it if send fails.