< prev index next >
src/java.base/windows/classes/java/net/TwoStacksPlainDatagramSocketImpl.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -103,12 +103,20 @@
@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 {
< prev index next >