Skip to content
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

Make sure wait() isn't called on the event loop #79

Merged
merged 1 commit into from
Aug 29, 2018

Conversation

pushkarnk
Copy link
Contributor

@pushkarnk pushkarnk commented Aug 28, 2018

This partly fixes #66

ClientRequest.end() makes the actual HTTP request, the response for which is received over the HTTPClientHandler. Further, the HTTPClientHandler may either execute HTTP redirection i.e creating a new ClientRequest or simply calling the callback supplied by the user. In both the cases we could again call ClientRequest.end() on the event loop. This isn't good because this method internally invokes ClientBootstrap.connect(...).wait() and swift-nio strictly disallows calling wait() on the event loop. This fix moves the redirection invocations and the callback invocations to a DispatchQueue. On the DispatchQueue, whenever we wish to work with the Channel, we call back into the event loop.

ClientRequest.end() makes the actual HTTP request, the response for which is received over the HTTPClientHandler.
Further, the HTTPClientHandler may either execute HTTP redirection i.e creating a new ClientRequest or simply
calling the `callback` supplied by the user. In both the cases we could again call ClientRequest.end() on the event loop.
This isn't good because this method internally invokes `ClientBootstrap.connect(...).wait()` and swift-nio strictly disallows
calling `wait()` on the event loop. This fix moves the redirection invocations and the callback invocations to a DispatchQueue.
On the DispatchQueue, whenever we wish to work with the `Channel`, we call back into the event loop.
@pushkarnk pushkarnk merged commit 3303ba2 into Kitura:master Aug 29, 2018
@pushkarnk pushkarnk deleted the clientrequest-dispatch branch September 11, 2018 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

KituraNIO's ClientRequest.end calls wait and may be called from an EventLoop
2 participants