0001-Fix-multicast-of-rinda.patch

Hiroshi Shirosaki, 04/06/2013 06:15 PM

Download (2.37 KB)

View differences:

lib/rinda/ring.rb
78 78
      @renewer = Renewer.new
79 79

  
80 80
      @ts = ts
81
      @sockets = addresses.map do |address|
81
      @sockets = []
82
      addresses.each do |address|
82 83
        make_socket(address)
83 84
      end
84 85

  
......
103 104
        end
104 105

  
105 106
        if addrinfo.ipv4_multicast? then
107
          socket.bind(Addrinfo.udp(Socket::INADDR_ANY, @port))
108

  
106 109
          mreq = IPAddr.new(addrinfo.ip_address).hton +
107 110
            IPAddr.new('0.0.0.0').hton
108 111

  
109 112
          socket.setsockopt(:IPPROTO_IP, :IP_ADD_MEMBERSHIP, mreq)
110 113
        else
114
          socket.bind(Addrinfo.udp(nil, @port))
115

  
111 116
          mreq = IPAddr.new(addrinfo.ip_address).hton + [0].pack('I')
112 117

  
113 118
          socket.setsockopt(:IPPROTO_IPV6, :IPV6_JOIN_GROUP, mreq)
114 119
        end
120
      else
121
        socket.bind(addrinfo)
115 122
      end
116 123

  
117
      socket.bind(addrinfo)
118

  
124
      @sockets << socket
119 125
      socket
120 126
    end
121 127

  
test/rinda/test_rinda.rb
570 570
      assert(v4mc.getsockopt(:SOCKET, :SO_REUSEADDR).bool)
571 571
    end
572 572

  
573
    assert_equal('239.0.0.1', v4mc.local_address.ip_address)
574
    assert_equal(@port,       v4mc.local_address.ip_port)
573
    assert_equal('0.0.0.0', v4mc.local_address.ip_address)
574
    assert_equal(@port,     v4mc.local_address.ip_port)
575 575
  end
576 576

  
577 577
  def test_make_socket_ipv6_multicast
......
590 590
      assert v6mc.getsockopt(:SOCKET, :SO_REUSEADDR).bool
591 591
    end
592 592

  
593
    assert_equal('ff02::1',  v6mc.local_address.ip_address)
593
    assert_equal('::1', v6mc.local_address.ip_address)
594 594
    assert_equal(@port, v6mc.local_address.ip_port)
595 595
  end
596 596

  
597
-