Commit fd71081
committed
Add controller flag 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 a controller-level flag that is automatically set when
set_after_rpc_resp_fn() is called. When the flag is true, ConcurrencyRemover's
lifetime is extended to cover CallAfterRpcResp.
Implementation:
- Add _concurrency_remover_manages_after_rpc_resp flag to Controller
- Automatically set flag to true in set_after_rpc_resp_fn()
- Use unique_ptr with explicit reset() for clear control flow
- Apply to both baidu_rpc_protocol and http_rpc_protocol
When false (default): Original behavior - ConcurrencyRemover is released before
CallAfterRpcResp via explicit reset().
When true (set_after_rpc_resp_fn called): ConcurrencyRemover lives until the
end of BRPC_SCOPE_EXIT, covering the entire response lifecycle including
after-response callbacks.1 parent a47e349 commit fd71081
4 files changed
Lines changed: 35 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
298 | 298 | | |
299 | 299 | | |
300 | 300 | | |
| 301 | + | |
301 | 302 | | |
302 | 303 | | |
303 | 304 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
621 | 621 | | |
622 | 622 | | |
623 | 623 | | |
624 | | - | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
625 | 629 | | |
626 | 630 | | |
627 | 631 | | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
628 | 637 | | |
629 | 638 | | |
630 | 639 | | |
| |||
921 | 930 | | |
922 | 931 | | |
923 | 932 | | |
| 933 | + | |
924 | 934 | | |
925 | 935 | | |
926 | 936 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
285 | 285 | | |
286 | 286 | | |
287 | 287 | | |
288 | | - | |
289 | | - | |
290 | | - | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
291 | 294 | | |
292 | 295 | | |
293 | 296 | | |
| |||
302 | 305 | | |
303 | 306 | | |
304 | 307 | | |
| 308 | + | |
| 309 | + | |
305 | 310 | | |
306 | 311 | | |
307 | 312 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
813 | 813 | | |
814 | 814 | | |
815 | 815 | | |
816 | | - | |
817 | | - | |
818 | | - | |
819 | | - | |
| 816 | + | |
820 | 817 | | |
821 | 818 | | |
822 | 819 | | |
| |||
827 | 824 | | |
828 | 825 | | |
829 | 826 | | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
830 | 838 | | |
| 839 | + | |
831 | 840 | | |
832 | 841 | | |
| 842 | + | |
| 843 | + | |
833 | 844 | | |
834 | 845 | | |
835 | 846 | | |
| |||
840 | 851 | | |
841 | 852 | | |
842 | 853 | | |
843 | | - | |
844 | 854 | | |
845 | 855 | | |
846 | 856 | | |
| |||
0 commit comments