mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8200304: TwoStacksPlainDatagramSocketImpl and socket cleaner
Reviewed-by: alanb, dfuchs, rriggs
This commit is contained in:
parent
5c124571d0
commit
71a0d523dd
2 changed files with 13 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* 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
|
||||
|
@ -40,7 +40,7 @@ import sun.net.ResourceManager;
|
|||
* @author Chris Hegarty
|
||||
*/
|
||||
|
||||
class TwoStacksPlainDatagramSocketImpl extends AbstractPlainDatagramSocketImpl
|
||||
final class TwoStacksPlainDatagramSocketImpl extends AbstractPlainDatagramSocketImpl
|
||||
{
|
||||
/* Used for IPv6 on Windows only */
|
||||
private FileDescriptor fd1;
|
||||
|
@ -105,8 +105,16 @@ class TwoStacksPlainDatagramSocketImpl extends AbstractPlainDatagramSocketImpl
|
|||
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)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 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
|
||||
|
@ -491,7 +491,9 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_bind0(JNIEnv *env, jobject this,
|
|||
if (WSAGetLastError() == WSAEACCES) {
|
||||
WSASetLastError(WSAEADDRINUSE);
|
||||
}
|
||||
(*env)->SetObjectField(env, this, pdsi_fdID, NULL);
|
||||
NET_ThrowCurrent(env, "Cannot bind");
|
||||
closesocket(fd);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue