Delay call to Destroy until after SignalDone has finished firing.
Bug: chromium:905542 Change-Id: I0def33a3ac21bd0da4b77ef05d42a0e7ef66caec Reviewed-on: https://webrtc-review.googlesource.com/c/112163 Commit-Queue: Zach Stein <zstein@webrtc.org> Reviewed-by: Qingsi Wang <qingsi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25807}
This commit is contained in:
@ -1098,7 +1098,9 @@ void P2PTransportChannel::OnCandidateResolved(
|
||||
Candidate candidate = p->candidate_;
|
||||
resolvers_.erase(p);
|
||||
AddRemoteCandidateWithResolver(candidate, resolver);
|
||||
resolver->Destroy(false);
|
||||
invoker_.AsyncInvoke<void>(
|
||||
RTC_FROM_HERE, thread(),
|
||||
rtc::Bind(&rtc::AsyncResolverInterface::Destroy, resolver, false));
|
||||
}
|
||||
|
||||
void P2PTransportChannel::AddRemoteCandidateWithResolver(
|
||||
|
@ -4565,13 +4565,18 @@ TEST_F(P2PTransportChannelMostLikelyToWorkFirstTest, TestTcpTurn) {
|
||||
}
|
||||
|
||||
// Test that a resolver is created, asked for a result, and destroyed
|
||||
// when the address is a hostname.
|
||||
// when the address is a hostname. The destruction should happen even
|
||||
// if the channel is not destroyed.
|
||||
TEST(P2PTransportChannelResolverTest, HostnameCandidateIsResolved) {
|
||||
rtc::MockAsyncResolver mock_async_resolver;
|
||||
EXPECT_CALL(mock_async_resolver, GetError()).WillOnce(Return(0));
|
||||
EXPECT_CALL(mock_async_resolver, GetResolvedAddress(_, _))
|
||||
.WillOnce(Return(true));
|
||||
EXPECT_CALL(mock_async_resolver, Destroy(_));
|
||||
// Destroy is called asynchronously after the address is resolved,
|
||||
// so we need a variable to wait on.
|
||||
bool destroy_called = false;
|
||||
EXPECT_CALL(mock_async_resolver, Destroy(_))
|
||||
.WillOnce(testing::Assign(&destroy_called, true));
|
||||
webrtc::MockAsyncResolverFactory mock_async_resolver_factory;
|
||||
EXPECT_CALL(mock_async_resolver_factory, Create())
|
||||
.WillOnce(Return(&mock_async_resolver));
|
||||
@ -4586,6 +4591,7 @@ TEST(P2PTransportChannelResolverTest, HostnameCandidateIsResolved) {
|
||||
ASSERT_EQ_WAIT(1u, channel.remote_candidates().size(), kDefaultTimeout);
|
||||
const RemoteCandidate& candidate = channel.remote_candidates()[0];
|
||||
EXPECT_FALSE(candidate.address().IsUnresolvedIP());
|
||||
WAIT(destroy_called, kShortTimeout);
|
||||
}
|
||||
|
||||
// Test that if we signal a hostname candidate after the remote endpoint
|
||||
|
Reference in New Issue
Block a user