Skip to content
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

Add assertions when handling connection errors #334

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions mojo/public/cpp/bindings/lib/connector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -665,14 +665,20 @@ void Connector::CancelWait() {
}

void Connector::HandleError(bool force_pipe_reset, bool force_async_handler) {
// https://linear.app/replay/issue/RUN-1123
recordreplay::Assert("[RUN-1123] Connector::HandleError %d %d %d",
recordreplay::PointerId(this), force_pipe_reset, force_async_handler);

if (error_ || !message_pipe_.is_valid()) {
// https://linear.app/replay/issue/RUN-1123
recordreplay::Assert("[RUN-1123] Connector::HandleError #1");
return;
}

if (paused_) {
// https://linear.app/replay/issue/RUN-1123
recordreplay::Assert("[RUN-1123] Connector::HandleError #2");

// Enforce calling the error handler asynchronously if the user has paused
// receiving messages. We need to wait until the user starts receiving
// messages again.
Expand All @@ -683,23 +689,38 @@ void Connector::HandleError(bool force_pipe_reset, bool force_async_handler) {
force_pipe_reset = true;

if (force_pipe_reset) {
// https://linear.app/replay/issue/RUN-1123
recordreplay::Assert("[RUN-1123] Connector::HandleError #3");

CancelWait();
internal::MayAutoLock locker(&lock_);
message_pipe_.reset();
MessagePipe dummy_pipe;
message_pipe_ = std::move(dummy_pipe.handle0);
} else {
// https://linear.app/replay/issue/RUN-1123
recordreplay::Assert("[RUN-1123] Connector::HandleError #4");

CancelWait();
}

if (force_async_handler) {
// https://linear.app/replay/issue/RUN-1123
recordreplay::Assert("[RUN-1123] Connector::HandleError #5 %d", paused_);

if (!paused_)
WaitToReadMore();
} else {
// https://linear.app/replay/issue/RUN-1123
recordreplay::Assert("[RUN-1123] Connector::HandleError #6 %d", !!connection_error_handler_);

error_ = true;
if (connection_error_handler_)
std::move(connection_error_handler_).Run();
}

// https://linear.app/replay/issue/RUN-1123
recordreplay::Assert("[RUN-1123] Connector::HandleError Done");
}

void Connector::EnsureSyncWatcherExists() {
Expand Down