-
-
Notifications
You must be signed in to change notification settings - Fork 7k
doswin: CloseHandle the thread on shutdown #18996
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
As this is in the tool shutdown the impact of it was nothing. Also, move two global variables to local. Follow-up to 9a26633 Reported-by: Joshua Rogers
|
The patch is fine, though zooming out, the use of (Up until recently, all other places used the CRT API for thread creation, and that API doesn't have a terminate API.) Earlier discussion: #18451 edit: Meant to say: If there is a way, this error handling should probably be solved differently, without killing the thread. |
It certainly sounds so, but I don't think I am the person to do that as it probably should involve running tests on Windows to work out what works and what doesn't work. It's not clear to me what the alternative is. |
|
I don't think we need to terminate the thread on error, it looks like it is written in a way that it would abort on its own? @denandz Though I notice that there's similar cleanup in both the main thread and the worker thread and that doesn't make a lot of sense to me. Couldn't it lead to handles being closed twice etc if the worker thread has started but there is an error in the main thread? main thread cleanup of tdata, sockets,etc: Lines 920 to 948 in 11b9912
worker thread cleanup of tdata, sockets,etc : Lines 794 to 806 in 11b9912
Should the worker thread really be doing any of that? |
|
That block in the main thread is cleaning up if there's any issue spawning the worker and its various handles. The in-worker-cleanup closes the socket handles after the worker main processing loop is completed. IIRC without the in-worker cleanup, I had the test suite catching unclosed-sockets on exit. The other bit was we need to call the socket close (along with the Regarding This could all probably be done in a neater way - like passing the |
|
Would it be workable to setup the sockets first, and only create the thread if those succeeded? |
Possibly - the I think there's two areas for improvement here - Moving away from Did we want to track this in a separate issue? I just tested this branch on a Windows host and the additional |
Yes, I think we should do it in a separate PR to keep it clean. I can merge this as-is in the mean time. |
As this is in the tool shutdown the impact of it was nothing.
Also, move two global variables to local.
Follow-up to 9a26633
Reported-by: Joshua Rogers