Skip to content

Commit f101378

Browse files
author
rmsousa@chromium.org
committed
Allow transport candidates to arrive before the authentication accepted message.
BUG=259598 Review URL: https://chromiumcodereview.appspot.com/18295009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@211558 0039d316-1c4b-4281-b951-d872f2087c98
1 parent 35c4053 commit f101378

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

remoting/protocol/jingle_session.cc

+22-4
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,20 @@ void JingleSession::Close() {
226226
CloseInternal(OK);
227227
}
228228

229+
void JingleSession::AddPendingRemoteCandidates(Transport* channel,
230+
const std::string& name) {
231+
std::list<JingleMessage::NamedCandidate>::iterator it =
232+
pending_remote_candidates_.begin();
233+
while(it != pending_remote_candidates_.end()) {
234+
if (it->name == name) {
235+
channel->AddRemoteCandidate(it->candidate);
236+
it = pending_remote_candidates_.erase(it);
237+
} else {
238+
++it;
239+
}
240+
}
241+
}
242+
229243
void JingleSession::CreateStreamChannel(
230244
const std::string& name,
231245
const StreamChannelCallback& callback) {
@@ -237,6 +251,7 @@ void JingleSession::CreateStreamChannel(
237251
session_manager_->transport_factory_->CreateStreamTransport();
238252
channel->Initialize(name, this, channel_authenticator.Pass());
239253
channel->Connect(callback);
254+
AddPendingRemoteCandidates(channel.get(), name);
240255
channels_[name] = channel.release();
241256
}
242257

@@ -251,6 +266,7 @@ void JingleSession::CreateDatagramChannel(
251266
session_manager_->transport_factory_->CreateDatagramTransport();
252267
channel->Initialize(name, this, channel_authenticator.Pass());
253268
channel->Connect(callback);
269+
AddPendingRemoteCandidates(channel.get(), name);
254270
channels_[name] = channel.release();
255271
}
256272

@@ -489,11 +505,13 @@ void JingleSession::ProcessTransportInfo(const JingleMessage& message) {
489505
message.candidates.begin();
490506
it != message.candidates.end(); ++it) {
491507
ChannelsMap::iterator channel = channels_.find(it->name);
492-
if (channel == channels_.end()) {
493-
LOG(WARNING) << "Received candidate for unknown channel " << it->name;
494-
continue;
508+
if (channel != channels_.end()) {
509+
channel->second->AddRemoteCandidate(it->candidate);
510+
} else {
511+
// Transport info was received before the channel was created.
512+
// This could happen due to messages being reordered on the wire.
513+
pending_remote_candidates_.push_back(*it);
495514
}
496-
channel->second->AddRemoteCandidate(it->candidate);
497515
}
498516
}
499517

remoting/protocol/jingle_session.h

+6
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ class JingleSession : public Session,
8686
scoped_ptr<Authenticator> authenticator,
8787
scoped_ptr<CandidateSessionConfig> config);
8888

89+
// Adds to a new channel the remote candidates received before it was created.
90+
void AddPendingRemoteCandidates(Transport* channel, const std::string& name);
91+
8992
// Called by JingleSessionManager for incoming connections.
9093
void InitializeIncomingConnection(const JingleMessage& initiate_message,
9194
scoped_ptr<Authenticator> authenticator);
@@ -166,6 +169,9 @@ class JingleSession : public Session,
166169
base::OneShotTimer<JingleSession> transport_infos_timer_;
167170
std::list<JingleMessage::NamedCandidate> pending_candidates_;
168171

172+
// Pending remote candidates, received before the local channels were created.
173+
std::list<JingleMessage::NamedCandidate> pending_remote_candidates_;
174+
169175
DISALLOW_COPY_AND_ASSIGN(JingleSession);
170176
};
171177

0 commit comments

Comments
 (0)