Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: remoting/protocol/jingle_session.cc

Issue 2911663004: [Chromoting] Drop unordered messages instead of crashing
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/protocol/jingle_session.h" 5 #include "remoting/protocol/jingle_session.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <limits> 9 #include <limits>
10 #include <memory> 10 #include <memory>
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 if (current == kInvalid) { 136 if (current == kInvalid) {
137 result.push_back(std::move(message)); 137 result.push_back(std::move(message));
138 return result; 138 return result;
139 } 139 }
140 140
141 if (next_incoming_ == kAny) { 141 if (next_incoming_ == kAny) {
142 next_incoming_ = current; 142 next_incoming_ = current;
143 } 143 }
144 144
145 // Ensure there are no duplicate sequence ids. 145 // Ensure there are no duplicate sequence ids.
146 DCHECK_GE(current, next_incoming_); 146 if (current < next_incoming_) {
147 DCHECK(queue_.find(current) == queue_.end()); 147 LOG(WARNING) << "An unordered message will be dropped, expected= "
148 148 << next_incoming_ << " current= " << current;
149 queue_.insert(std::make_pair(current, std::move(message))); 149 } else {
150 DCHECK(queue_.find(current) == queue_.end());
151 queue_.insert(std::make_pair(current, std::move(message)));
152 }
150 153
151 auto it = queue_.begin(); 154 auto it = queue_.begin();
152 while (it != queue_.end() && it->first == next_incoming_) { 155 while (it != queue_.end() && it->first == next_incoming_) {
153 result.push_back(std::move(it->second)); 156 result.push_back(std::move(it->second));
154 it = queue_.erase(it); 157 it = queue_.erase(it);
155 next_incoming_++; 158 next_incoming_++;
156 } 159 }
157 160
158 if (current - next_incoming_ >= 3) { 161 if (current - next_incoming_ >= 3) {
159 LOG(WARNING) << "Multiple messages are missing: expected= " 162 LOG(WARNING) << "Multiple messages are missing: expected= "
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 authenticator_->GetNextMessage())); 803 authenticator_->GetNextMessage()));
801 SendMessage(std::move(message)); 804 SendMessage(std::move(message));
802 } 805 }
803 806
804 std::string JingleSession::GetNextOutgoingId() { 807 std::string JingleSession::GetNextOutgoingId() {
805 return outgoing_id_prefix_ + "_" + base::IntToString(++next_outgoing_id_); 808 return outgoing_id_prefix_ + "_" + base::IntToString(++next_outgoing_id_);
806 } 809 }
807 810
808 } // namespace protocol 811 } // namespace protocol
809 } // namespace remoting 812 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698