Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 7d22b206f6d7
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0e48f7b42396
Choose a head ref
  • 3 commits
  • 2 files changed
  • 2 contributors

Commits on Sep 29, 2016

  1. Implement TCPServer#sysaccept.

    headius authored and etehtsea committed Sep 29, 2016
    Copy the full SHA
    026cb61 View commit details
  2. Untag TCPServer#sysaccept

    etehtsea committed Sep 29, 2016
    Copy the full SHA
    8435a4a View commit details

Commits on Sep 30, 2016

  1. Merge pull request #4189 from etehtsea/tcpserver-sysaccept

    Implement TCPServer#sysaccept
    headius authored Sep 30, 2016
    Copy the full SHA
    0e48f7b View commit details
Showing with 30 additions and 2 deletions.
  1. +30 −0 core/src/main/java/org/jruby/ext/socket/RubyTCPServer.java
  2. +0 −2 spec/tags/ruby/library/socket/tcpserver/sysaccept_tags.txt
30 changes: 30 additions & 0 deletions core/src/main/java/org/jruby/ext/socket/RubyTCPServer.java
Original file line number Diff line number Diff line change
@@ -52,6 +52,7 @@
import org.jruby.runtime.Visibility;
import org.jruby.runtime.builtin.IRubyObject;

import org.jruby.util.io.FilenoUtil;
import org.jruby.util.io.SelectorFactory;
import java.nio.channels.spi.SelectorProvider;

@@ -236,6 +237,35 @@ public IRubyObject accept_nonblock(ThreadContext context, Ruby runtime, boolean
}
}

@JRubyMethod(name = "sysaccept")
public IRubyObject sysaccept(ThreadContext context) {
Ruby runtime = context.runtime;

try {
RubyThread thread = context.getThread();

while (true) {
boolean ready = thread.select(this, SelectionKey.OP_ACCEPT);

if (!ready) {
// we were woken up without being selected...poll for thread events and go back to sleep
context.pollThreadEvents();

} else {
SocketChannel connected = getServerSocketChannel().accept();
if (connected == null) continue;

connected.finishConnect();

return runtime.newFixnum(FilenoUtil.filenoFrom(connected));
}
}

} catch(IOException e) {
throw runtime.newIOErrorFromException(e);
}
}

@JRubyMethod(name = "listen", required = 1)
public IRubyObject listen(ThreadContext context, IRubyObject backlog) {
return RubyFixnum.zero(context.runtime);
2 changes: 0 additions & 2 deletions spec/tags/ruby/library/socket/tcpserver/sysaccept_tags.txt

This file was deleted.