Commit eed1207
Add gflag to manage ConcurrencyRemover lifecycle for CallAfterRpcResp
In SendRpcResponse, ConcurrencyRemover was destroyed before CallAfterRpcResp
was called, meaning concurrency control didn't cover the after-response callback.
This could lead to inaccurate concurrency tracking and latency measurements.
This change adds FLAGS_concurrency_remover_manages_after_rpc_resp (default: false)
and automatically sets it to controller when set_after_rpc_resp_fn is called.
Implementation:
- Add _concurrency_remover_manages_after_rpc_resp flag to Controller
- In set_after_rpc_resp_fn(), read gflag value and set to controller instance
- In baidu_rpc_protocol, use controller flag instead of global gflag
- Use unique_ptr with explicit reset() for clear control flow
When false (default): Original behavior - ConcurrencyRemover is released before
CallAfterRpcResp via explicit reset().
When true (gflag enabled when callback set): ConcurrencyRemover lives until the
end of BRPC_SCOPE_EXIT, covering the entire response lifecycle.
Note: HTTP protocol not modified in this change due to its more complex async
flow. Can be addressed separately if needed.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent a47e349 commit eed1207
3 files changed
Lines changed: 30 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
| 130 | + | |
130 | 131 | | |
131 | 132 | | |
132 | 133 | | |
| |||
298 | 299 | | |
299 | 300 | | |
300 | 301 | | |
| 302 | + | |
301 | 303 | | |
302 | 304 | | |
303 | 305 | | |
| |||
1593 | 1595 | | |
1594 | 1596 | | |
1595 | 1597 | | |
| 1598 | + | |
| 1599 | + | |
| 1600 | + | |
| 1601 | + | |
| 1602 | + | |
| 1603 | + | |
1596 | 1604 | | |
1597 | 1605 | | |
1598 | 1606 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
621 | 621 | | |
622 | 622 | | |
623 | 623 | | |
624 | | - | |
| 624 | + | |
625 | 625 | | |
626 | 626 | | |
627 | 627 | | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
628 | 633 | | |
629 | 634 | | |
630 | 635 | | |
| |||
921 | 926 | | |
922 | 927 | | |
923 | 928 | | |
| 929 | + | |
924 | 930 | | |
925 | 931 | | |
926 | 932 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
65 | 70 | | |
66 | 71 | | |
67 | 72 | | |
| |||
285 | 290 | | |
286 | 291 | | |
287 | 292 | | |
288 | | - | |
289 | | - | |
290 | | - | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
291 | 301 | | |
292 | 302 | | |
293 | 303 | | |
| |||
302 | 312 | | |
303 | 313 | | |
304 | 314 | | |
| 315 | + | |
| 316 | + | |
305 | 317 | | |
306 | 318 | | |
307 | 319 | | |
| |||
0 commit comments