Skip to content

Commit

Permalink
Len arg is in/out so remove @out annotation
Browse files Browse the repository at this point in the history
Specifying that this is only @out prevents the referenced length
from being copied to the native buffer. This in turn causes
getsockopt to sometimes get invalid length values, since the
allocate memory may be uninitialized (or if zeroed, zero is an
invalid length as well). Removing @out makes this an in/out var
and the given length gets copied to native before the getsockopt
call.

Fixes intermittent "EINVAL" errors when calling getsockopt.
  • Loading branch information
headius committed Oct 9, 2024
1 parent 939e940 commit 5abdc75
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ public interface LibC {
int F_SETFL = jnr.constants.platform.Fcntl.F_SETFL.intValue();
int O_NONBLOCK = jnr.constants.platform.OpenFlags.O_NONBLOCK.intValue();

int getsockopt(int s, int level, int optname, @Out ByteBuffer optval, @Out IntByReference optlen);
int getsockopt(int s, int level, int optname, @Out ByteBuffer optval, IntByReference optlen);
int setsockopt(int s, int level, int optname, @In ByteBuffer optval, int optlen);
int setsockopt(int s, int level, int optname, @In Timeval optval, int optlen);
}
Expand Down

0 comments on commit 5abdc75

Please sign in to comment.