Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Use WinHttpCloseHandle from another thread to cancel the http request. #568
Use WinHttpCloseHandle from another thread to cancel the http request. #568
Changes from 1 commit
aca6ff2
047b2c6
4841459
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a question: Shouldn’t these be closed in a particular order, in this case request first? Also, while it does not really make a difference, why is this reset to
0
while the others useNULL
?Also, since this can race with the background thread, might it be a good idea to exchange
state->request
first before closing it? So the racing background thread does not try to double-close it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes the order is important. Closing the session first will cancel all other requests in the queue as well.
When the request handle is closed, the background blocking function is unblocked and the loop continues. But because of no session handle all WinHttp requests will fail and the queue will get cleaned up.
This is not a nice solution, but still the best I could com up with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanation why the ordering is important. It might be a good idea to put that as a comment in the code.
I also saw that all the tests are failing, I think in that case also the ordering is important.
The main thread will ask the background thread to shut down here according to the timeout. I think you have to move all your close calls after this call here, because you do want to wait for the given timeout, instead of just throwing away all the requests that are currently in flight.