Skip to content

Conversation

@ysbaddaden
Copy link
Contributor

@ysbaddaden ysbaddaden commented Oct 28, 2025

Extract the #before_close(io) #shutdown(io) method out of the #close method to distinguish the different aspects of closing:

  • #shutdown(io) does the cleanup after closing the IO object but before closing the actual system (socket) fd or handle.

  • #close(io) closes the system (socket) fd or handle.

Required by #16289 (then #16209) to fix #16127.

Similar to #16145 but using a specific callback because event loops might have a different behavior in after reopen than before close.

@straight-shoota straight-shoota modified the milestone: 1.19.0 Oct 28, 2025
@ysbaddaden
Copy link
Contributor Author

Refactored to now use #shutdown(io).

@ysbaddaden ysbaddaden force-pushed the refactor/add-event-loop-before-close-hook branch from c792df9 to 28bc979 Compare October 30, 2025 17:21
ysbaddaden added a commit to ysbaddaden/crystal that referenced this pull request Oct 30, 2025
@ysbaddaden ysbaddaden changed the title Extract Crystal::EventLoop#before_close from #close Extract Crystal::EventLoop#shutdown from #close Oct 30, 2025
ysbaddaden added a commit to ysbaddaden/crystal that referenced this pull request Oct 30, 2025
Co-authored-by: Johannes Müller <[email protected]>
@straight-shoota straight-shoota added this to the 1.19.0 milestone Oct 30, 2025
@straight-shoota straight-shoota merged commit bf6dba5 into crystal-lang:master Oct 31, 2025
45 of 46 checks passed
@ysbaddaden ysbaddaden deleted the refactor/add-event-loop-before-close-hook branch October 31, 2025 23:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Closing fd is thread unsafe on UNIX targets

2 participants