-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure QuicChromiumPacketWriter isn't still tracked when deleted. #4691
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -411,7 +411,7 @@ void QuicConnection::InstallInitialCrypters(QuicConnectionId connection_id) { | |
|
||
QuicConnection::~QuicConnection() { | ||
QUICHE_DCHECK_GE(stats_.max_egress_mtu, long_term_mtu_); | ||
if (owns_writer_) { | ||
if (writer_ != nullptr && owns_writer_) { | ||
delete writer_; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should it do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I considered doing that, but elsewhere that boolean is only ever used when the pointer is not nullptr. |
||
} | ||
ClearQueuedPackets(); | ||
|
@@ -2439,7 +2439,7 @@ QuicPacketNumber QuicConnection::GetLeastUnacked() const { | |
} | ||
|
||
bool QuicConnection::HandleWriteBlocked() { | ||
if (!writer_->IsWriteBlocked()) { | ||
if (writer_ != nullptr && !writer_->IsWriteBlocked()) { | ||
return false; | ||
} | ||
|
||
|
@@ -2808,12 +2808,14 @@ void QuicConnection::ProcessUdpPacket(const QuicSocketAddress& self_address, | |
} | ||
|
||
void QuicConnection::OnBlockedWriterCanWrite() { | ||
writer_->SetWritable(); | ||
OnCanWrite(); | ||
if (writer_) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tiny style inconsistency nitpick: Above you are writing out There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I followed the pre-existing pattern already used elsewhere in this file for consistency |
||
writer_->SetWritable(); | ||
OnCanWrite(); | ||
} | ||
} | ||
|
||
void QuicConnection::OnCanWrite() { | ||
if (!connected_) { | ||
if (!connected_ || !writer_) { | ||
return; | ||
} | ||
if (writer_->IsWriteBlocked()) { | ||
|
@@ -6911,6 +6913,10 @@ bool QuicConnection::MigratePath(const QuicSocketAddress& self_address, | |
QUICHE_DCHECK(perspective_ == Perspective::IS_CLIENT); | ||
if (!connected_) { | ||
if (owns_writer) { | ||
if (writer_ == writer) { | ||
writer_ = nullptr; | ||
owns_writer_ = false; | ||
} | ||
delete writer; | ||
} | ||
return false; | ||
|
@@ -6921,6 +6927,10 @@ bool QuicConnection::MigratePath(const QuicSocketAddress& self_address, | |
if (connection_migration_use_new_cid_) { | ||
if (!UpdateConnectionIdsOnMigration(self_address, peer_address)) { | ||
if (owns_writer) { | ||
if (writer_ == writer) { | ||
writer_ = nullptr; | ||
owns_writer_ = false; | ||
} | ||
delete writer; | ||
} | ||
return false; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It shouldn't matter where you call this. Does the weak pointer need to be invalidated before the
QuicChromiumPacketReader
instance gets destroyed? If you so, you can callweak_factory_.InvalidateWeakPtrs()
.Every time the weak pointer is treated like a bool, the WeakReference is checked to see if it's still valid.