This is an automated email from the ASF dual-hosted git repository.

serverglen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brpc.git


The following commit(s) were added to refs/heads/master by this push:
     new 17a200c2 Fix cancel callback may be called twice (#2557)
17a200c2 is described below

commit 17a200c24e1e7463367a38dac99c062a102550d0
Author: Bright Chen <[email protected]>
AuthorDate: Tue Mar 12 10:21:28 2024 +0800

    Fix cancel callback may be called twice (#2557)
---
 src/brpc/controller.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/brpc/controller.cpp b/src/brpc/controller.cpp
index bfe278ff..825c05cd 100644
--- a/src/brpc/controller.cpp
+++ b/src/brpc/controller.cpp
@@ -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();
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to