namespace net {
-QuicServerSession::QuicServerSession(
- const QuicConfig& config,
- QuicConnection* connection,
- QuicServerSessionVisitor* visitor)
- : QuicSession(connection, config),
+QuicServerSession::QuicServerSession(const QuicConfig& config,
+ QuicConnection* connection,
+ QuicServerSessionVisitor* visitor,
+ bool is_secure)
+ : QuicSession(connection, config, is_secure),
visitor_(visitor),
bandwidth_estimate_sent_to_client_(QuicBandwidth::Zero()),
- last_server_config_update_time_(QuicTime::Zero()) {}
+ last_scup_time_(QuicTime::Zero()),
+ last_scup_sequence_number_(0) {}
QuicServerSession::~QuicServerSession() {}
QuicSession::OnConnectionClosed(error, from_peer);
// In the unlikely event we get a connection close while doing an asynchronous
// crypto event, make sure we cancel the callback.
- if (crypto_stream_.get() != NULL) {
+ if (crypto_stream_.get() != nullptr) {
crypto_stream_->CancelOutstandingCallbacks();
}
visitor_->OnConnectionClosed(connection()->connection_id(), error);
}
// If not enough time has passed since the last time we sent an update to the
- // client, then return early.
+ // client, or not enough packets have been sent, then return early.
const QuicSentPacketManager& sent_packet_manager =
connection()->sent_packet_manager();
int64 srtt_ms =
- sent_packet_manager.GetRttStats()->SmoothedRtt().ToMilliseconds();
- int64 now_ms = now.Subtract(last_server_config_update_time_).ToMilliseconds();
+ sent_packet_manager.GetRttStats()->smoothed_rtt().ToMilliseconds();
+ int64 now_ms = now.Subtract(last_scup_time_).ToMilliseconds();
+ int64 packets_since_last_scup =
+ connection()->sequence_number_of_last_sent_packet() -
+ last_scup_sequence_number_;
if (now_ms < (kMinIntervalBetweenServerConfigUpdatesRTTs * srtt_ms) ||
- now_ms < kMinIntervalBetweenServerConfigUpdatesMs) {
+ now_ms < kMinIntervalBetweenServerConfigUpdatesMs ||
+ packets_since_last_scup < kMinPacketsBetweenServerConfigUpdates) {
return;
}
bandwidth_recorder.EstimateRecordedDuringSlowStart()
? CachedNetworkParameters::SLOW_START
: CachedNetworkParameters::CONGESTION_AVOIDANCE);
+ cached_network_params.set_timestamp(
+ connection()->clock()->WallNow().ToUNIXSeconds());
if (!serving_region_.empty()) {
cached_network_params.set_serving_region(serving_region_);
}
crypto_stream_->SendServerConfigUpdate(&cached_network_params);
- last_server_config_update_time_ = now;
+ last_scup_time_ = now;
+ last_scup_sequence_number_ =
+ connection()->sequence_number_of_last_sent_packet();
}
bool QuicServerSession::ShouldCreateIncomingDataStream(QuicStreamId id) {
QuicDataStream* QuicServerSession::CreateIncomingDataStream(
QuicStreamId id) {
if (!ShouldCreateIncomingDataStream(id)) {
- return NULL;
+ return nullptr;
}
return new QuicSpdyServerStream(id, this);
QuicDataStream* QuicServerSession::CreateOutgoingDataStream() {
DLOG(ERROR) << "Server push not yet supported";
- return NULL;
+ return nullptr;
}
QuicCryptoServerStream* QuicServerSession::GetCryptoStream() {