Skip to content

Commit

Permalink
Remove all tuples when ICE consent is ended, but do it right
Browse files Browse the repository at this point in the history
  • Loading branch information
ibc committed Feb 19, 2024
1 parent 215380e commit 7ee1753
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions worker/src/RTC/IceServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,14 @@ namespace RTC
this->listener->OnIceServerTupleRemoved(this, storedTuple);
}

// Clear all tuples.
// NOTE: Do it after notifying the listener since the listener may need to
// use/read the tuple being removed so we cannot free it yet.
this->tuples.clear();

// Unset selected tuple.
this->selectedTuple = nullptr;

// Clear queue of ongoing sent ICE consent request.
this->sentConsents.clear();

Expand Down Expand Up @@ -1095,18 +1101,32 @@ namespace RTC
// Update state.
this->state = IceState::DISCONNECTED;

// Unset the selected tuple.
this->selectedTuple = nullptr;

// Reset remote nomination.
this->remoteNomination = 0u;

// Stop ICE consent check.
MayStopConsentCheck();

// Notify the listener.
this->listener->OnIceServerTupleRemoved(this, disconnectedSelectedTuple);
this->listener->OnIceServerDisconnected(this);

// Clear all tuples.
for (const auto& it : this->tuples)
{
auto* storedTuple = const_cast<RTC::TransportTuple*>(std::addressof(it));

// Notify the listener.
this->listener->OnIceServerTupleRemoved(this, storedTuple);
}

// Clear all tuples.
// NOTE: Do it after notifying the listener since the listener may need to
// use/read the tuple being removed so we cannot free it yet.
this->tuples.clear();

// Unset selected tuple.
this->selectedTuple = nullptr;

// Stop ICE consent check.
MayStopConsentCheck();
}

inline void IceServer::OnTimer(TimerHandle* timer)
Expand Down

0 comments on commit 7ee1753

Please sign in to comment.