Skip to content

Commit

Permalink
Avoid to block the timer thread in HandleSocketFailed
Browse files Browse the repository at this point in the history
  • Loading branch information
chenBright committed Sep 20, 2024
1 parent 0b9208f commit 6a69c2d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/brpc/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,13 @@ void Controller::OnVersionedRPCReturned(const CompletionInfo& info,
goto END_OF_RPC;
}
if (_error_code == EBACKUPREQUEST) {
if (NULL != _backup_request_policy && !_backup_request_policy->DoBackup(this)) {
// No need to do backup request.
_error_code = saved_error;
CHECK_EQ(0, bthread_id_unlock(info.id));
return;
}

// Reset timeout if needed
int rc = 0;
if (timeout_ms() >= 0) {
Expand Down Expand Up @@ -1278,11 +1285,6 @@ int Controller::HandleSocketFailed(bthread_id_t id, void* data, int error_code,
cntl->timeout_ms(),
butil::endpoint2str(cntl->remote_side()).c_str());
} else if (error_code == EBACKUPREQUEST) {
BackupRequestPolicy* policy = cntl->_backup_request_policy;
if (NULL != policy && !policy->DoBackup(cntl)) {
// No need to do backup request.
return bthread_id_unlock(id);
}
cntl->SetFailed(error_code, "Reached backup timeout=%" PRId64 "ms @%s",
cntl->backup_request_ms(),
butil::endpoint2str(cntl->remote_side()).c_str());
Expand Down

0 comments on commit 6a69c2d

Please sign in to comment.