Skip to content

Commit

Permalink
meh unsure
Browse files Browse the repository at this point in the history
  • Loading branch information
jellefoks committed Dec 3, 2024
1 parent 33a55f0 commit 187d718
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 7 deletions.
12 changes: 6 additions & 6 deletions net/quic/quic_chromium_packet_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,7 @@ int QuicChromiumPacketReader::StartReadingMultiplePackets() {
}

bool QuicChromiumPacketReader::ProcessMultiplePacketReadResult(int result) {
if (visitor_ && result > 0) {
visitor_->set_force_write_blocked(true);
}
bool success = ProcessMultiplePacketReadResultInternal(result);
if (visitor_ && result > 0) {
visitor_->set_force_write_blocked(false);
}
return success;
}

Expand Down Expand Up @@ -161,8 +155,14 @@ bool QuicChromiumPacketReader::ProcessMultiplePacketReadResultInternal(
}

void QuicChromiumPacketReader::OnReadMultiplePacketComplete(int result) {
if (visitor_ && result > 0) {
visitor_->set_force_write_blocked(true);
}
if (ProcessMultiplePacketReadResult(result))
StartReadingMultiplePackets();
if (visitor_ && result > 0) {
visitor_->set_force_write_blocked(false);
}
}

#endif
Expand Down
35 changes: 34 additions & 1 deletion net/third_party/quiche/src/quiche/quic/core/quic_connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,10 @@ QuicConnection::~QuicConnection() {
}
}

void QuicConnection::ClearQueuedPackets() { buffered_packets_.clear(); }
void QuicConnection::ClearQueuedPackets() {
LOG(INFO) << __FUNCTION__ << " " << buffered_packets_.size();
buffered_packets_.clear();
}

bool QuicConnection::ValidateConfigConnectionIds(const QuicConfig& config) {
QUICHE_DCHECK(config.negotiated());
Expand Down Expand Up @@ -2407,6 +2410,7 @@ void QuicConnection::CloseIfTooManyOutstandingSentPackets() {
sent_packet_manager_.GetLeastUnacked() + max_tracked_packets_;

if (should_close) {
LOG(INFO) << __FUNCTION__ << "\n\n*************************\n\n";
CloseConnection(
QUIC_TOO_MANY_OUTSTANDING_SENT_PACKETS,
absl::StrCat("More than ", max_tracked_packets_,
Expand Down Expand Up @@ -2819,6 +2823,7 @@ void QuicConnection::OnCanWrite() {
if (writer_->IsWriteBlocked()) {
const std::string error_details =
"Writer is blocked while calling OnCanWrite.";
LOG(INFO) << __FUNCTION__ << " " << error_details;
QUIC_BUG(quic_bug_10511_22) << ENDPOINT << error_details;
CloseConnection(QUIC_INTERNAL_ERROR, error_details,
ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET);
Expand Down Expand Up @@ -3117,6 +3122,25 @@ bool QuicConnection::ValidateReceivedPacketNumber(
}

void QuicConnection::WriteQueuedPackets() {
static int cnt = 0;
static int count = 0;
static int singles = 0;
static int multiples = 0;
++count;
if (buffered_packets_.size() > 1) {
multiples += buffered_packets_.size();
} else {
++singles;
}
if (++cnt > 99) {
cnt = 0;
LOG(INFO) << __FUNCTION__ << " " << buffered_packets_.size()
<< " count=" << count << " singles=" << singles
<< " mutiples=" << (double)multiples / (count - singles);
count = 0;
singles = 0;
multiples = 0;
}
QUICHE_DCHECK(!writer_->IsWriteBlocked());
#if !defined(STARBOARD)
QUIC_CLIENT_HISTOGRAM_COUNTS("QuicSession.NumQueuedPacketsBeforeWrite",
Expand All @@ -3125,6 +3149,7 @@ void QuicConnection::WriteQueuedPackets() {

while (!buffered_packets_.empty()) {
if (HandleWriteBlocked()) {
LOG(INFO) << __FUNCTION__;
break;
}
const BufferedPacket& packet = buffered_packets_.front();
Expand All @@ -3133,6 +3158,7 @@ void QuicConnection::WriteQueuedPackets() {
packet.peer_address, per_packet_options_);
QUIC_DVLOG(1) << ENDPOINT << "Sending buffered packet, result: " << result;
if (IsMsgTooBig(writer_, result) && packet.length > long_term_mtu_) {
LOG(INFO) << __FUNCTION__;
// When MSG_TOO_BIG is returned, the system typically knows what the
// actual MTU is, so there is no need to probe further.
// TODO(wub): Reduce max packet size to a safe default, or the actual MTU.
Expand All @@ -3142,6 +3168,7 @@ void QuicConnection::WriteQueuedPackets() {
continue;
}
if (IsWriteError(result.status)) {
LOG(INFO) << __FUNCTION__;
OnWriteError(result.error_code);
break;
}
Expand All @@ -3150,6 +3177,7 @@ void QuicConnection::WriteQueuedPackets() {
buffered_packets_.pop_front();
}
if (IsWriteBlockedStatus(result.status)) {
LOG(INFO) << __FUNCTION__;
visitor_->OnWriteBlocked();
break;
}
Expand Down Expand Up @@ -3543,6 +3571,7 @@ bool QuicConnection::WritePacket(SerializedPacket* packet) {
// duplicate packet being sent. The helper must call OnCanWrite
// when the write completes, and OnWriteError if an error occurs.
if (result.status != WRITE_STATUS_BLOCKED_DATA_BUFFERED) {
LOG(INFO) << __FUNCTION__;
QUIC_DVLOG(1) << ENDPOINT << "Adding packet: " << packet->packet_number
<< " to buffered packets";
buffered_packets_.emplace_back(*packet, send_from_address,
Expand Down Expand Up @@ -4539,6 +4568,7 @@ bool QuicConnection::MaybeProcessCoalescedPackets() {
void QuicConnection::CloseConnection(
QuicErrorCode error, const std::string& details,
ConnectionCloseBehavior connection_close_behavior) {
LOG(INFO) << __FUNCTION__ << " " << details << " *************************";
CloseConnection(error, NO_IETF_QUIC_ERROR, details,
connection_close_behavior);
}
Expand Down Expand Up @@ -5071,6 +5101,7 @@ bool QuicConnection::SendConnectivityProbingPacket(
QUIC_DLOG(INFO)
<< ENDPOINT
<< "Writer blocked when sending connectivity probing packet.";
LOG(INFO) << __FUNCTION__;
if (probing_writer == writer_) {
// Visitor should not be write blocked if the probing writer is not the
// default packet writer.
Expand Down Expand Up @@ -5877,6 +5908,8 @@ void QuicConnection::SendAllPendingAcks() {
static_cast<PacketNumberSpace>(i), clock_->ApproximateNow()));
const bool flushed = packet_creator_.FlushAckFrame(frames);
if (!flushed) {
LOG(INFO) << __FUNCTION__;
CHECK(!writer_->IsWriteBlocked());
// Connection is write blocked.
QUIC_BUG_IF(quic_bug_12714_33,
!writer_->IsWriteBlocked() &&
Expand Down

0 comments on commit 187d718

Please sign in to comment.