Skip to content

Commit

Permalink
Revert "simple fix. Socket read return -1 for error."
Browse files Browse the repository at this point in the history
Ruby 3.3 changes recv(0) to nil and 9.4 is 3.1.

This reverts commit 5a8ab05.
  • Loading branch information
enebo committed May 31, 2024
1 parent 5a8ab05 commit 890c9c7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions core/src/main/java/org/jruby/ext/socket/RubyBasicSocket.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,9 @@ private IRubyObject recv(ThreadContext context, IRubyObject length,
return null; // not reached
}
} else {
bytes = doRead(context, buffer);
if (bytes == null) return context.nil;
bytes = doRead(context, buffer);
}
if (bytes == null) return context.nil;

if (str != null) {
str.setValue(bytes);
Expand Down Expand Up @@ -738,7 +738,8 @@ protected ByteList doRead(ThreadContext context, final ByteBuffer buffer) {
context.getThread().beforeBlockingCall(context);

int read = openFile.readChannel().read(buffer);
if (read <= 0) return null;

if (read == 0) return null;

return new ByteList(buffer.array(), 0, buffer.position(), false);
} catch (Exception e) {
Expand Down

0 comments on commit 890c9c7

Please sign in to comment.