feng-y commented on PR #3309:
URL: https://github.com/apache/brpc/pull/3309#issuecomment-4550876687
I've updated the implementation based on the feedback:
## Current Implementation
### ✅ What Changed
1. **Kept the gflag**: `FLAGS_concurrency_remover_manages_after_rpc_resp`
(default: false)
2. **Capture to controller**: In `set_after_rpc_resp_fn()`, the gflag value
is captured to the controller instance
3. **Protocol uses controller flag**: `baidu_rpc_protocol` now uses
`cntl->concurrency_remover_manages_after_rpc_resp()` instead of the global gflag
### 🎯 How It Works
```cpp
// 1. User optionally sets global gflag
// -concurrency_remover_manages_after_rpc_resp=true
// 2. User sets callback (in service implementation)
controller.set_after_rpc_resp_fn([](Controller* cntl, ...) {
// At this point, the gflag value is captured to controller
// _concurrency_remover_manages_after_rpc_resp =
FLAGS_concurrency_remover_manages_after_rpc_resp
});
// 3. In SendRpcResponse
if (!cntl->concurrency_remover_manages_after_rpc_resp()) {
concurrency_remover_ptr.reset(); // Release early (default)
}
```
### 📝 Scope
- **Modified**: `baidu_rpc_protocol` only
- **Not modified**: `http_rpc_protocol`
- HTTP has a more complex async flow (`HttpResponseSenderAsDone`)
- Can be addressed separately if needed
- Wanted to keep this PR focused and low-risk
### ✅ Benefits
- Global configuration via gflag
- Per-controller instance capture (no race conditions)
- Backward compatible (default behavior unchanged)
- Minimal changes (only 3 files, +19 -3 lines)
Let me know if you'd like me to also update HTTP protocol, or if we should
handle that separately!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]