Commit bf8fe49
authored
fix: ensure Python backend shm cleanup on forced shutdown (#450)
* fix: ensure Python backend shm cleanup on forced shutdown
Register parent-owned shm regions for atexit cleanup, remove regions
explicitly in TerminateStub, and honor stub-timeout-seconds during stub
teardown to avoid orphaned regions when server exit times out.
* style: fix pre-commit (copyright bump + clang-format)
- Bump copyright to 2021-2026 on src/shm_manager.{cc,h}.
- Collapse wrapped stub_timeout_seconds_ assignment per clang-format.
* fix: address Greptile review — bounded total shutdown budget
- Enforce stub_timeout_seconds_ as a single total budget across the
finalize-wait and process-exit-wait phases; healthy teardown previously
could take up to 2 * stub_timeout_seconds_.
- Clamp the Pop timeout to INT_MAX to avoid narrowing when passing int64_t
into MessageQueue::Pop(int const&).
- Re-poll waitpid once after the final sleep window in
WaitForStubProcessWithTimeout so a stub that exits during that second is
not force-killed unnecessarily.
* polish: log atexit registration failure; trim comments
- Log a warning to stderr if std::atexit registration fails so the loss of
the last-resort shm cleanup is visible; primary cleanup path is unaffected.
- Tighten inline comments to explain only intent/constraints, not mechanics.
* refactor: inline shm cleanup callback into atexit registration
CleanupParentShmRegions was only referenced as the std::atexit callback
inside RegisterParentShmRegion. Inline it as a capture-less lambda so the
teardown logic lives next to the registration and there's one fewer
top-level helper in the anonymous namespace.
No behavior change.1 parent f9088ff commit bf8fe49
4 files changed
Lines changed: 130 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| 33 | + | |
32 | 34 | | |
| 35 | + | |
| 36 | + | |
33 | 37 | | |
34 | 38 | | |
35 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
36 | 77 | | |
37 | 78 | | |
38 | 79 | | |
| |||
139 | 180 | | |
140 | 181 | | |
141 | 182 | | |
| 183 | + | |
142 | 184 | | |
143 | 185 | | |
144 | 186 | | |
| |||
226 | 268 | | |
227 | 269 | | |
228 | 270 | | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
229 | 277 | | |
230 | 278 | | |
231 | 279 | | |
| 280 | + | |
| 281 | + | |
232 | 282 | | |
233 | 283 | | |
234 | 284 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
197 | 200 | | |
198 | 201 | | |
199 | 202 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
29 | 31 | | |
| 32 | + | |
30 | 33 | | |
31 | 34 | | |
32 | 35 | | |
| |||
42 | 45 | | |
43 | 46 | | |
44 | 47 | | |
45 | | - | |
| 48 | + | |
46 | 49 | | |
47 | 50 | | |
48 | 51 | | |
| |||
51 | 54 | | |
52 | 55 | | |
53 | 56 | | |
54 | | - | |
| 57 | + | |
55 | 58 | | |
56 | 59 | | |
57 | 60 | | |
| |||
64 | 67 | | |
65 | 68 | | |
66 | 69 | | |
| 70 | + | |
67 | 71 | | |
68 | 72 | | |
69 | 73 | | |
| |||
801 | 805 | | |
802 | 806 | | |
803 | 807 | | |
| 808 | + | |
804 | 809 | | |
| 810 | + | |
805 | 811 | | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
806 | 817 | | |
807 | 818 | | |
808 | 819 | | |
809 | 820 | | |
810 | 821 | | |
811 | 822 | | |
812 | | - | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
813 | 835 | | |
814 | 836 | | |
815 | 837 | | |
| |||
820 | 842 | | |
821 | 843 | | |
822 | 844 | | |
823 | | - | |
824 | | - | |
| 845 | + | |
| 846 | + | |
825 | 847 | | |
826 | 848 | | |
827 | 849 | | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
828 | 854 | | |
829 | 855 | | |
830 | 856 | | |
| |||
924 | 950 | | |
925 | 951 | | |
926 | 952 | | |
| 953 | + | |
927 | 954 | | |
928 | 955 | | |
929 | 956 | | |
930 | 957 | | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
931 | 997 | | |
932 | 998 | | |
933 | 999 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
164 | 167 | | |
165 | 168 | | |
166 | 169 | | |
| |||
199 | 202 | | |
200 | 203 | | |
201 | 204 | | |
| 205 | + | |
202 | 206 | | |
203 | 207 | | |
204 | 208 | | |
| |||
0 commit comments