Fix use of lwt_io + conduit-tls#328
Merged
Merged
Conversation
3 tasks
Member
Author
|
Ok, it seems that the first-recv behavior of |
Member
Author
|
The real conclusion of this patch is: don't use |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
According to the documentation of
conduit-tls, the implementation withocaml-tlsis not thread-safe, something likeboth (send flow) (recv flow)is unsafe. It's mostly about the wrapping of aConduit.flowwithLwt_io- because theflowcan be a TLS flow, we must protectrecvandsendwith a mutex anyway.The question behind such patch is: should we protect
conduit-tlswith a mutex - and by this way, we are not mandatory to protect anyflowwith a mutex or should we keep this design? To this existential question, we should make an issue a talk about this issue later - note that this is not a part of the core ofconduit.The second patch is about the first-read behavior of
Lwt_io. I'm not sure how we can properly schedule that but it seems that theLwt_iowants to read first when we start a TLS connection - I suspect that it schedule the action from the underlying state of the socket and, because we receive a part of the handshake, it considersConduit.recvas the first operation. However, for the HTTP/1.1 point-of-view, this is not true when the server expect to receive something - so client and server expect to receive something at the end.conduit-tlsis able to produce an opportunity to scheduleConduit.sendeven if we calledConduit.recv, it returnsInput 0(which means that we received nothing, but the connection still is established). On the other side,recvgiven toLwt_iocan yield to give the opportunity to the application to schedulerConduit.send/Lwt_io.write.Finally:
conduit-tlsis a bit hard but an issue will be done which describe precisely the situationlwt_iois an inheritance of 1) and it seems thattls.lwtfix it in its own way