Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.6
    • Fix Version/s: JRuby 1.7.0.pre1
    • Component/s: Core Classes/Modules
    • Labels:
      None
    • Environment:
      Mac OS X Snow Leopard 64-bit
    • Number of attachments :
      0

      Description

      The following code blocks in MRI, but returns immediately in JRuby:

      {{
      require 'socket'
      server = UNIXServer.open "/tmp/#

      {rand}

      .sock"
      IO.select [server], nil, nil, 20
      }}

        Activity

        Hide
        Wayne Meissner added a comment -

        We should probably look at using jnr-unixsocket (https://github.com/jnr/jnr-unixsocket) in JRuby - it provides NIO selectable unix sockets, though, with a unix-socket specific Selector implementation, which might complicate things.

        Show
        Wayne Meissner added a comment - We should probably look at using jnr-unixsocket ( https://github.com/jnr/jnr-unixsocket ) in JRuby - it provides NIO selectable unix sockets, though, with a unix-socket specific Selector implementation, which might complicate things.
        Hide
        Charles Oliver Nutter added a comment -

        Yeah, sounds like a good idea to me. The one we have is doing basically the same thing, just not as well.

        We also need to get a fd-based selectable Channel in general...does what's in jnr-unixsocket give us a leg up there?

        Show
        Charles Oliver Nutter added a comment - Yeah, sounds like a good idea to me. The one we have is doing basically the same thing, just not as well. We also need to get a fd-based selectable Channel in general...does what's in jnr-unixsocket give us a leg up there?
        Hide
        Charles Oliver Nutter added a comment -

        This causes a problem with POW too. Would be nice to roll this into 1.6.2

        Show
        Charles Oliver Nutter added a comment - This causes a problem with POW too. Would be nice to roll this into 1.6.2
        Hide
        Ryan Baumann added a comment -

        This failing testcase may be of help to anyone else looking into this:

        diff --git a/test/test_socket.rb b/test/test_socket.rb
        index d4838f3..5298161 100644
        --- a/test/test_socket.rb
        +++ b/test/test_socket.rb
        @@ -273,6 +273,29 @@ class UNIXSocketTests < Test::Unit::TestCase
               File.unlink(path) if File.exist?(path)
             end
         
        +    # JRUBY-5708
        +    def test_can_create_socket_server_and_blocking_select_blocks_on_it
        +      require 'timeout'
        +
        +      path = "/tmp/sample"
        +
        +      File.unlink(path) if File.exist?(path)
        +
        +      sock = UNIXServer.open(path)
        +
        +      assert File.exist?(path)
        +
        +      assert_raises(Timeout::Error) do
        +        Timeout::timeout(0.1) do
        +          IO.select [sock], nil, nil, 0.2
        +        end
        +      end
        +
        +      sock.close
        +
        +      File.unlink(path) if File.exist?(path)
        +    end
        +
             def test_can_create_socket_server_and_client_connected_to_it
               path = "/tmp/sample"
         
        
        Show
        Ryan Baumann added a comment - This failing testcase may be of help to anyone else looking into this: diff --git a/test/test_socket.rb b/test/test_socket.rb index d4838f3..5298161 100644 --- a/test/test_socket.rb +++ b/test/test_socket.rb @@ -273,6 +273,29 @@ class UNIXSocketTests < Test::Unit::TestCase File.unlink(path) if File.exist?(path) end + # JRUBY-5708 + def test_can_create_socket_server_and_blocking_select_blocks_on_it + require 'timeout' + + path = "/tmp/sample" + + File.unlink(path) if File.exist?(path) + + sock = UNIXServer.open(path) + + assert File.exist?(path) + + assert_raises(Timeout::Error) do + Timeout::timeout(0.1) do + IO.select [sock], nil, nil, 0.2 + end + end + + sock.close + + File.unlink(path) if File.exist?(path) + end + def test_can_create_socket_server_and_client_connected_to_it path = "/tmp/sample"
        Hide
        Charles Oliver Nutter added a comment -

        Fixed in commits leading up to master@159240e.

        commit 71f1b3e2194c7bc60ee2ed057b653f410f5de6e6
        Author: Charles Oliver Nutter <headius@headius.com>
        Date:   Mon Mar 12 15:52:25 2012 -0500
        
            Move to using jnr-unixsocket for UNIXSocket and UNIXServer.
        
        commit 3767e7fc413d46155de20135ce987f172c897a73
        Author: Charles Oliver Nutter <headius@headius.com>
        Date:   Mon Mar 12 17:27:30 2012 -0500
        
            Refactoring, cleanup, and test-passing for new UNIX sockets.
        
        commit 159240eec548e38ddd7228490fe2553b1cf543ce
        Author: Charles Oliver Nutter <headius@headius.com>
        Date:   Mon Mar 12 17:30:14 2012 -0500
        
            Add test for blocking IO.select on UNIX server.
        

        Thanks for the test!

        Show
        Charles Oliver Nutter added a comment - Fixed in commits leading up to master@159240e. commit 71f1b3e2194c7bc60ee2ed057b653f410f5de6e6 Author: Charles Oliver Nutter <headius@headius.com> Date: Mon Mar 12 15:52:25 2012 -0500 Move to using jnr-unixsocket for UNIXSocket and UNIXServer. commit 3767e7fc413d46155de20135ce987f172c897a73 Author: Charles Oliver Nutter <headius@headius.com> Date: Mon Mar 12 17:27:30 2012 -0500 Refactoring, cleanup, and test-passing for new UNIX sockets. commit 159240eec548e38ddd7228490fe2553b1cf543ce Author: Charles Oliver Nutter <headius@headius.com> Date: Mon Mar 12 17:30:14 2012 -0500 Add test for blocking IO.select on UNIX server. Thanks for the test!

          People

          • Assignee:
            Charles Oliver Nutter
            Reporter:
            David Lee
          • Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: