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
cleanup: refactor and use bicopy everywhere #2944
base: master
Are you sure you want to change the base?
cleanup: refactor and use bicopy everywhere #2944
Changes from all commits
553ebd9
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.
Any reason to accept io.ReadWriter and not a net.Con? This is not a library for general use, but a lima helper specific to forwarding packets around.
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.
GrpcClientRW
doesn't implementnet.Conn
.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.
How do we ensure that the entire Bicopy() finish when one of the io.Copy() finish?
I think this can be done if we do:
Second issue, do we really need the broker function? it is pretty simple, and it may be more clear to see the entire flow in one function like we have today in vz/network_drawin.go.
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.
Why does it matter? We're always running
Bicopy
in a goroutine, and we don't have this guarantee on any of the code paths today.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.
We don't ensure this today, so it should not block your change. Current code assumes that if we fail to read or write from socket and io.Copy() returns, the other io.Copy() will also returns since it is trying to read of write using the same socket. This may be enough, but I'm not sure.
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.
Looking at io.Copy implementation:
It will not return io.EOF from the copy loop - but it may delegate the copy to ReadFrom() or WriteTo(), which can be implemented by the actual types we copy. I don't think we have any guarantee that we will never get io.EOF.
So it may be better to keep this if we don't want to report it as an error.
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.
ReadFrom
is not permitted to return EOF:https://cs.opensource.google/go/go/+/refs/tags/go1.23.4:src/io/io.go;l=186
WriteTo
returns "Any error encountered during the write":https://cs.opensource.google/go/go/+/refs/tags/go1.23.4:src/io/io.go;l=197
EOF does not occur on write, only on read.
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.
Nice but previously we got an more specific log about the tunnel.
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.
We could include the caller's file and line number in the error message?
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.
Nice but previously the logs were more specific to this package.