On 29/03/2018 11:10, Chris Hegarty wrote:
:
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);
       }

This is much simpler but are there any cases where bind0 will throw an exception with open sockets? It looks like the !ipv6_supported case might do that when the native bind fails (the ipv6_supported case seems to clean up).

-Alan

Reply via email to