Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.7.0.pre1
    • Fix Version/s: JRuby 1.7.0.pre2
    • Component/s: Standard Library
    • Labels:
      None
    • Environment:
       jruby 1.7.0.dev (ruby-1.9.3-p139) (2012-04-30 4e6078d) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_26) [linux-amd64-java]
    • Number of attachments :
      0

      Description

      UDPSocket send seems to be working fine without the multicast.

      jruby-head :001 > require 'socket'
       => true 
      jruby-head :002 > require 'ipaddr'
       => true 
      jruby-head :003 > @multicast_ip = "239.221.222.59"
       => "239.221.222.59" 
      jruby-head :004 > @port = 25464
       => 25464 
      jruby-head :005 > SOCKET_TIMEOUT = 1
       => 1 
      jruby-head :006 >   def create_multicast_socket
      jruby-head :007?>       ip = IPAddr.new(@multicast_ip).hton + IPAddr.new("0.0.0.0").hton
      jruby-head :008?>       socket = UDPSocket.open
      jruby-head :009?>       socket.setsockopt(Socket::IPPROTO_IP, Socket::IP_MULTICAST_TTL, "\x01\x00\x00\x00")
      jruby-head :010?>       socket.setsockopt(Socket::IPPROTO_IP, Socket::IP_ADD_MEMBERSHIP, ip)
      jruby-head :011?>       socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR, 1)
      jruby-head :012?>   
      jruby-head :013 >         optval = [SOCKET_TIMEOUT, 0].pack("l_2")
      jruby-head :014?>       socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_SNDTIMEO, optval)
      jruby-head :015?>   
      jruby-head :016 >         socket
      jruby-head :017?>     end
       => nil 
      jruby-head :018 > 
      jruby-head :019 >   sender = create_multicast_socket
       => #<UDPSocket:fd 87> 
      jruby-head :020 > send
      send     sender   
      jruby-head :020 > sender.send("Test Data.", 0, @multicast_ip, @port)
      Java::JavaLang::NullPointerException: 
      	from org.jruby.ext.socket.RubyUDPSocket.send(RubyUDPSocket.java:307)
      	from org.jruby.ext.socket.RubyUDPSocket$INVOKER$i$send.call(RubyUDPSocket$INVOKER$i$send.gen)
      	from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:282)
      	from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:71)
      	from org.jruby.ast.CallManyArgsNode.interpret(CallManyArgsNode.java:59)
      	from org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
      	from org.jruby.ast.RootNode.interpret(RootNode.java:129)
      	from org.jruby.evaluator.ASTInterpreter.INTERPRET_EVAL(ASTInterpreter.java:96)
      	from org.jruby.evaluator.ASTInterpreter.evalWithBinding(ASTInterpreter.java:167)
      	from org.jruby.RubyKernel.evalCommon(RubyKernel.java:1075)
      	from org.jruby.RubyKernel.eval19(RubyKernel.java:1037)
      	from org.jruby.RubyKernel$INVOKER$s$0$3$eval19.call(RubyKernel$INVOKER$s$0$3$eval19.gen)
      	from org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:186)
      	from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:69)
      	from org.jruby.ast.FCallManyArgsNode.interpret(FCallManyArgsNode.java:60)
      	from org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
      ... 116 levels...
      	from org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:75)
      	from org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:190)
      	from org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:199)
      	from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:312)
      	from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:169)
      	from home.developer.$_dot_rvm.rubies.jruby_minus_head.bin.irb.__file__(/home/developer/.rvm/rubies/jruby-head/bin/irb:17)
      	from home.developer.$_dot_rvm.rubies.jruby_minus_head.bin.irb.load(/home/developer/.rvm/rubies/jruby-head/bin/irb)
      	from org.jruby.Ruby.runScript(Ruby.java:780)
      	from org.jruby.Ruby.runScript(Ruby.java:773)
      	from org.jruby.Ruby.runNormally(Ruby.java:650)
      	from org.jruby.Ruby.runFromMain(Ruby.java:499)
      	from org.jruby.Main.doRunFromMain(Main.java:375)
      	from org.jruby.Main.internalRun(Main.java:264)
      	from org.jruby.Main.run(Main.java:230)
      	from org.jruby.Main.run(Main.java:214)
      	
      

      Although there is a work around.

      ruby-head :028 >   sender.connect(@multicast_ip, @port)
       => 0 
      jruby-head :029 > sender.send("Test Data.", 0)
       => 10 
      jruby-head :030 >
      

      This behaviour is only seen with multicast sockets.

        Activity

        Hide
        Charles Oliver Nutter added a comment -

        Confirmed still broken on master. Investigating.

        Show
        Charles Oliver Nutter added a comment - Confirmed still broken on master. Investigating.
        Hide
        Charles Oliver Nutter added a comment -

        Please confirm this with more extensive code. Seems to be working with this fix.

        commit 46f42400360a354bfd32127af9bb9e888747c099
        Author: Charles Oliver Nutter <headius@headius.com>
        Date:   Thu Aug 2 12:06:18 2012 -0500
        
            Fix JRUBY-6638
            
            Multicast UDPSocket send does not work with host and port
            
            It appears we were simply not binding to a port, which meant that
            no MulticastSocket was ever created. Added that, and the given
            case passes.
        
        :100644 100644 2dd9553... b7a5a8a... M	src/org/jruby/ext/socket/RubyUDPSocket.java
        
        Show
        Charles Oliver Nutter added a comment - Please confirm this with more extensive code. Seems to be working with this fix. commit 46f42400360a354bfd32127af9bb9e888747c099 Author: Charles Oliver Nutter <headius@headius.com> Date: Thu Aug 2 12:06:18 2012 -0500 Fix JRUBY-6638 Multicast UDPSocket send does not work with host and port It appears we were simply not binding to a port, which meant that no MulticastSocket was ever created. Added that, and the given case passes. :100644 100644 2dd9553... b7a5a8a... M src/org/jruby/ext/socket/RubyUDPSocket.java
        Hide
        Sujin Philip added a comment -

        Fix verified in JRuby 1.7.0.pre2

        Show
        Sujin Philip added a comment - Fix verified in JRuby 1.7.0.pre2

          People

          • Assignee:
            Charles Oliver Nutter
            Reporter:
            Sujin Philip
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: