Commit 6e759c2
committed
Fix coroutine frame leaks and IOCP shutdown hang (#159)
Coroutine frames were leaked during shutdown because destroy handlers
skipped h.destroy(). post_handler::destroy() and completion_op::destroy()
now destroy the coroutine frame in all backends. timer_service::shutdown()
destroys frames instead of nulling handles.
Fix IOCP shutdown hang caused by service ordering: execution_context
creates timer_service from win_scheduler's constructor before prepending
win_scheduler to the service list, so shutdown() calls the scheduler
first. Its work-counting drain loop spun forever because timer heap
waiters hadn't been released. Fix by calling timer_svc_->shutdown()
early, matching Asio's pattern. Restructure the IOCP drain loop to
match Asio: drain completed_ops first, poll GQCS only when empty,
decrement outstanding_work before each destroy.
Remove dead shutdown_ flag from all backends. Remove force-reset of
outstanding_work_ from non-IOCP backends. Add bounded-destruction
depth guard to IOCP post_handler. Widen timing budget in
testExpiresAtCancelsWaiter for Windows CI.
Add regression tests for shutdown: posted coroutine frames, timer
waiters, timer heap drain, abrupt stop with pending ops, and
IOCP-specific completion draining.1 parent 6eaf03d commit 6e759c2
File tree
8 files changed
+468
-54
lines changed- include/boost/corosio
- detail
- native/detail
- epoll
- iocp
- kqueue
- select
- test/unit
- native/iocp
8 files changed
+468
-54
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
198 | 199 | | |
199 | 200 | | |
200 | 201 | | |
201 | | - | |
202 | | - | |
| 202 | + | |
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
| |||
328 | 328 | | |
329 | 329 | | |
330 | 330 | | |
331 | | - | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
332 | 337 | | |
333 | 338 | | |
334 | 339 | | |
335 | 340 | | |
336 | 341 | | |
337 | 342 | | |
338 | | - | |
| 343 | + | |
339 | 344 | | |
| 345 | + | |
| 346 | + | |
340 | 347 | | |
341 | 348 | | |
342 | 349 | | |
| |||
722 | 729 | | |
723 | 730 | | |
724 | 731 | | |
725 | | - | |
| 732 | + | |
726 | 733 | | |
727 | | - | |
728 | | - | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
729 | 738 | | |
730 | 739 | | |
731 | 740 | | |
| |||
748 | 757 | | |
749 | 758 | | |
750 | 759 | | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
751 | 784 | | |
752 | 785 | | |
753 | 786 | | |
| |||
Lines changed: 2 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
288 | 288 | | |
289 | 289 | | |
290 | 290 | | |
291 | | - | |
292 | 291 | | |
293 | 292 | | |
294 | 293 | | |
| |||
612 | 611 | | |
613 | 612 | | |
614 | 613 | | |
615 | | - | |
616 | 614 | | |
617 | 615 | | |
618 | 616 | | |
| |||
696 | 694 | | |
697 | 695 | | |
698 | 696 | | |
699 | | - | |
700 | 697 | | |
701 | 698 | | |
702 | 699 | | |
| |||
710 | 707 | | |
711 | 708 | | |
712 | 709 | | |
713 | | - | |
714 | | - | |
715 | 710 | | |
716 | 711 | | |
717 | 712 | | |
| |||
736 | 731 | | |
737 | 732 | | |
738 | 733 | | |
| 734 | + | |
739 | 735 | | |
| 736 | + | |
740 | 737 | | |
741 | 738 | | |
742 | 739 | | |
| |||
Lines changed: 57 additions & 30 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | | - | |
104 | 103 | | |
105 | 104 | | |
106 | 105 | | |
| |||
162 | 161 | | |
163 | 162 | | |
164 | 163 | | |
165 | | - | |
166 | 164 | | |
167 | 165 | | |
168 | 166 | | |
| |||
194 | 192 | | |
195 | 193 | | |
196 | 194 | | |
197 | | - | |
198 | | - | |
199 | 195 | | |
200 | 196 | | |
201 | 197 | | |
202 | | - | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
203 | 208 | | |
204 | 209 | | |
205 | 210 | | |
206 | 211 | | |
207 | 212 | | |
208 | 213 | | |
209 | 214 | | |
210 | | - | |
211 | | - | |
212 | | - | |
| 215 | + | |
213 | 216 | | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
| 217 | + | |
225 | 218 | | |
226 | | - | |
227 | | - | |
| 219 | + | |
| 220 | + | |
228 | 221 | | |
229 | | - | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
230 | 232 | | |
231 | | - | |
232 | | - | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
233 | 245 | | |
234 | | - | |
235 | 246 | | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | 247 | | |
240 | | - | |
241 | | - | |
242 | 248 | | |
243 | 249 | | |
244 | 250 | | |
| |||
254 | 260 | | |
255 | 261 | | |
256 | 262 | | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
257 | 280 | | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
258 | 285 | | |
259 | 286 | | |
260 | 287 | | |
| |||
Lines changed: 2 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
363 | 363 | | |
364 | 364 | | |
365 | 365 | | |
366 | | - | |
367 | 366 | | |
368 | 367 | | |
369 | 368 | | |
| |||
709 | 708 | | |
710 | 709 | | |
711 | 710 | | |
712 | | - | |
713 | 711 | | |
714 | 712 | | |
715 | 713 | | |
| |||
764 | 762 | | |
765 | 763 | | |
766 | 764 | | |
767 | | - | |
768 | 765 | | |
769 | 766 | | |
770 | 767 | | |
| |||
778 | 775 | | |
779 | 776 | | |
780 | 777 | | |
781 | | - | |
782 | | - | |
783 | 778 | | |
784 | 779 | | |
785 | 780 | | |
| |||
808 | 803 | | |
809 | 804 | | |
810 | 805 | | |
| 806 | + | |
811 | 807 | | |
| 808 | + | |
812 | 809 | | |
813 | 810 | | |
814 | 811 | | |
| |||
Lines changed: 2 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
159 | | - | |
160 | 159 | | |
161 | 160 | | |
162 | 161 | | |
| |||
259 | 258 | | |
260 | 259 | | |
261 | 260 | | |
262 | | - | |
263 | 261 | | |
264 | 262 | | |
265 | 263 | | |
| |||
325 | 323 | | |
326 | 324 | | |
327 | 325 | | |
328 | | - | |
329 | 326 | | |
330 | 327 | | |
331 | 328 | | |
| |||
337 | 334 | | |
338 | 335 | | |
339 | 336 | | |
340 | | - | |
341 | | - | |
342 | 337 | | |
343 | 338 | | |
344 | 339 | | |
| |||
365 | 360 | | |
366 | 361 | | |
367 | 362 | | |
| 363 | + | |
368 | 364 | | |
| 365 | + | |
369 | 366 | | |
370 | 367 | | |
371 | 368 | | |
| |||
0 commit comments