You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem is triggered in the code below by changing to a multicast socket after the bind has happened. In our logic, we defer creating the JDK-level socket object as long as possible, since it is generally not possible to change socket type after that point. setsockopt with IP_ADD_MEMBERSHIP triggers us to flip to using multicast sockets, but without a subsequent bind the actual multicast socket object is never created. That leads to the NPE.
The sequence used in this code is found (for example) in rinda/ring.rb, which binds and then adds membership (at least in the 2.2 version).
The code below should exit normally and the recvfrom should block without raising NPE.
require'socket'require'ipaddr'MULTICAST_ADDR='239.255.255.250'LOCATOR_PORT=24067membership=IPAddr.new(MULTICAST_ADDR).hton + IPAddr.new("0.0.0.0").htonsock=UDPSocket.opensock.setsockopt(Socket::SOL_SOCKET,Socket::SO_REUSEADDR,1)beginsock.bind(Socket::INADDR_ANY,LOCATOR_PORT)rescueErrno::EADDRINUSEp:hereraiseError,"Unable to listen on port #{LOCATOR_PORT},"endsock.setsockopt(Socket::IPPROTO_IP,Socket::IP_ADD_MEMBERSHIP,membership)Thread.new{sleep5puts"Exited normally"exit}sock.recvfrom(100)
The text was updated successfully, but these errors were encountered:
From http://jira.codehaus.org/browse/JRUBY-7070.
The problem is triggered in the code below by changing to a multicast socket after the bind has happened. In our logic, we defer creating the JDK-level socket object as long as possible, since it is generally not possible to change socket type after that point. setsockopt with IP_ADD_MEMBERSHIP triggers us to flip to using multicast sockets, but without a subsequent bind the actual multicast socket object is never created. That leads to the NPE.
The sequence used in this code is found (for example) in rinda/ring.rb, which binds and then adds membership (at least in the 2.2 version).
The code below should exit normally and the recvfrom should block without raising NPE.
The text was updated successfully, but these errors were encountered: