Skip to content

Commit

Permalink
Fix cancel callback may be called twice (apache#2557)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenBright authored Mar 12, 2024
1 parent e289c76 commit 17a200c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/brpc/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,15 +552,15 @@ void Controller::NotifyOnCancel(google::protobuf::Closure* callback) {
LOG(FATAL) << "NotifyCancel a single call more than once!";
return;
}
if (bthread_id_create(&_oncancel_id, callback, RunOnCancel) != 0) {
PLOG(FATAL) << "Fail to create bthread_id";
return;
}
SocketUniquePtr sock;
if (Socket::Address(_current_call.peer_id, &sock) != 0) {
// Connection already broken
return;
}
if (bthread_id_create(&_oncancel_id, callback, RunOnCancel) != 0) {
PLOG(FATAL) << "Fail to create bthread_id";
return;
}
sock->NotifyOnFailed(_oncancel_id); // Always succeed
guard.release();
}
Expand Down

0 comments on commit 17a200c

Please sign in to comment.