> On 28 Mar 2018, at 20:47, Chris Hegarty <chris.hega...@oracle.com> wrote: > ... > Right, unconditionally unregistering and re-registering would be easier > to follow, and then try-finally would not be required either. I’ll try this, > test it, and report back.
This is much simpler. @Override protected synchronized void bind0(int lport, InetAddress laddr) throws SocketException { + // The native bind0 may close one or both of the underlying file + // descriptors, and even create new sockets, so the safest course of + // action is to unregister the socket cleaners, and register afterwards. + SocketCleanable.unregister(fd); + SocketCleanable.unregister(fd1); + bind0(lport, laddr, exclusiveBind); + + SocketCleanable.register(fd); + SocketCleanable.register(fd1); } protected synchronized void receive(DatagramPacket p) throws IOException { try { webrev: http://cr.openjdk.java.net/~chegar/8200304/01/ -Chris.