From be1ed945df17d43a676f35b3708b1d76f6306834 Mon Sep 17 00:00:00 2001 From: mkoch Date: Tue, 2 Dec 2003 15:23:23 +0000 Subject: [PATCH] 2003-12-02 Michael Koch * java/net/DatagramSocket.java (close): Close associated DatagramChannel object. * java/net/ServerSocket.java * java/net/Socket.java (close): Reset impl and bound before calling getChannel().close() to prevent from loops. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@74183 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/ChangeLog | 9 +++++++++ libjava/java/net/DatagramSocket.java | 10 ++++++++++ libjava/java/net/ServerSocket.java | 7 +++---- libjava/java/net/Socket.java | 5 ++--- 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 409bf3b8745..82873fe60bd 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,5 +1,14 @@ 2003-12-02 Michael Koch + * java/net/DatagramSocket.java + (close): Close associated DatagramChannel object. + * java/net/ServerSocket.java + * java/net/Socket.java + (close): Reset impl and bound before calling getChannel().close() to + prevent from loops. + +2003-12-02 Michael Koch + * java/nio/channels/spi/AbstractInterruptibleChannel.java (opened): Removed. (closed): New field. diff --git a/libjava/java/net/DatagramSocket.java b/libjava/java/net/DatagramSocket.java index f4bc4ea79d5..e3edfcd6c39 100644 --- a/libjava/java/net/DatagramSocket.java +++ b/libjava/java/net/DatagramSocket.java @@ -232,6 +232,16 @@ public class DatagramSocket remotePort = -1; impl = null; } + + try + { + if (getChannel() != null) + getChannel().close(); + } + catch (IOException e) + { + // Do nothing. + } } } diff --git a/libjava/java/net/ServerSocket.java b/libjava/java/net/ServerSocket.java index 7af1a3301c0..4e7f58a7cfc 100644 --- a/libjava/java/net/ServerSocket.java +++ b/libjava/java/net/ServerSocket.java @@ -356,12 +356,11 @@ public class ServerSocket if (!isClosed()) { impl.close(); + impl = null; + bound = false; if (getChannel() != null) getChannel().close(); - - impl = null; - bound = false; } } @@ -543,7 +542,7 @@ public class ServerSocket if (!isBound()) return "ServerSocket[unbound]"; - return ("ServerSocket[addr=" + impl.getInetAddress() + return ("ServerSocket[addr=" + getInetAddress() + ",port=" + impl.getPort() + ",localport=" + impl.getLocalPort() + "]"); diff --git a/libjava/java/net/Socket.java b/libjava/java/net/Socket.java index 27fa69131b5..a0f831c1701 100644 --- a/libjava/java/net/Socket.java +++ b/libjava/java/net/Socket.java @@ -1006,12 +1006,11 @@ public class Socket throw new SocketException("socket is closed"); getImpl().close(); + impl = null; + bound = false; if (getChannel() != null) getChannel().close(); - - impl = null; - bound = false; } /** -- 2.11.4.GIT