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

channels/Common: only allocate temp buffers for read and write if nec… #49

Closed
wants to merge 1 commit into from

Conversation

athanatos
Copy link

…essary

jnr-ffi seems to be ok with array backed or direct buffers, so just pass
those right on through.

Signed-off-by: Samuel Just [email protected]

…essary

jnr-ffi seems to be ok with array backed or direct buffers, so just pass
those right on through.

Signed-off-by: Samuel Just <[email protected]>
@athanatos
Copy link
Author

Should fix #48

@athanatos
Copy link
Author

Seems it failed CI due to:

3.04s$ mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
The JAVA_HOME environment variable is not defined correctly
This environment variable is needed to run this program
NB: JAVA_HOME should point to a JDK not a JRE
The command "eval mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V " failed. Retrying, 2 of 3.

which I think is unrelated?

@athanatos
Copy link
Author

@headius Does this look right?

@@ -44,13 +44,19 @@ int getFD() {

int read(ByteBuffer dst) throws IOException {

ByteBuffer buffer = ByteBuffer.allocate(dst.remaining());
int n;
if (!dst.hasArray() && !dst.isDirect()) {
Copy link
Contributor

@huntc huntc Nov 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do this additional check at all? Why not call Native.read directly with dst. I can't see why the new allocation is required even for non-direct mode. Native.read appears to be agnostic to the type of byte buffer, and if there is something to be done, then the JNI call-site is the best place for those concerns.

@@ -92,13 +98,18 @@ long read(ByteBuffer[] dsts, int offset, int length)

int write(ByteBuffer src) throws IOException {

ByteBuffer buffer = ByteBuffer.allocate(src.remaining());
int n;
if (!src.hasArray() && !src.isDirect()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per my comment for read.

@huntc
Copy link
Contributor

huntc commented Nov 24, 2017

@athanatos Nothing appears weird about Travis - perhaps retry it?

@huntc
Copy link
Contributor

huntc commented Nov 24, 2017

@headius Are you the best committer to review/merge once the issues are sorted?


buffer.put(src);
buffer.put(src);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is incorrect as per #50 as the src position is updated to limit, which it should be updated by n (bytes written)

@headius
Copy link
Member

headius commented May 16, 2018

@athanatos Did you get a chance to address @gregw review comments? I can spin a release with this update any time, if we get those issues tidied up.

@headius
Copy link
Member

headius commented Jan 9, 2020

I'm going to close this for lack of activity. If you can rebase on master and address review comments, we can still get this in!

@headius headius closed this Jan 9, 2020
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.

4 participants