diff options
author | Michael Koch <konqueror@gmx.de> | 2004-02-06 09:13:23 +0000 |
---|---|---|
committer | Michael Koch <konqueror@gmx.de> | 2004-02-06 09:13:23 +0000 |
commit | 9c4f694033cff2a2c955ec9aa1bd7baf874fc06e (patch) | |
tree | 0bc0828df239ad3bf211635f564e7240804b9e5e /java | |
parent | c01c55fe280172bac8de0271571874fcd0b5d2c3 (diff) | |
download | classpath-9c4f694033cff2a2c955ec9aa1bd7baf874fc06e.tar.gz |
2004-02-06 Michael Koch <konqueror@gmx.de>
* gnu/java/nio/NIOServerSocket.java
(impl): Unused, removed.
* gnu/java/nio/SocketChannelImpl.java
(finnishConnect): Don't throw NoConnectionPendingException if not
connected or no connection pending.
2004-02-06 Mohan Embar <gnustuff@thisiscool.com>
* gnu/java/nio/DatagramChannelImpl.java
(inChannelOperation): New field.
(isInChannelOperation): New accessor.
(setInChannelOperation): New modifier.
(receive): Use capacity() - position() of destination
buffer instead of remaining(). Set and reset our "in
channel operation indicator" before and after delegating
the receive to our datagram socket. Removed testing code.
Update destination buffer's current position if it is
backed by a byte array (hasArray() is true).
(send): Set and reset our "in channel operation indicator"
before and after delegating the send to our datagram socket.
Removed testing code. Update source buffer's current position
if it is backed by a byte array (hasArray() is true).
* gnu/java/nio/SocketChannelImpl.java (read(ByteBuffer)):
Use capacity() - position() of destination buffer instead
of remaining().
* java/net/DatagramSocket.java (receive): Don't throw an
IllegalBlockingModeException if we have a non-blocking
channel which initiated this operation.
(send): Likewise.
2004-02-06 Mohan Embar <gnustuff@thisiscool.com>
* gnu/java/net/PlainSocketImpl.java
(inChannelOperation): New field.
(isInChannelOperation): New accessor.
(setInChannelOperation): New modifier.
* gnu/java/nio/ServerSocketChannelImpl.java
(accept): Set and reset our server socket's PlainSocketImpl's
"in channel operation" indicator before and after delegating
the accept to our server socket.
* gnu/java/nio/SocketChannelImpl.java
(connect): Set and reset our socket's PlainSocketImpl's "in channel
operation" indicator before and after delegating the operation to
our socket.
(read): Likewise.
(write): Likewise.
* java/net/ServerSocket.java (implAccept): Don't throw an
IllegalBlockingModeException if we have a non-blocking
channel which initiated this accept operation.
* java/net/Socket.java (connect): Don't throw an
IllegalBlockingModeException if we have a non-blocking
channel which initiated this connect operation.
* java/nio/channels/spi/AbstractSelectableChannel.java
(configureBlocking): Only call implConfigureBlocking() if
the desired blocking mode is different from our current one.
Diffstat (limited to 'java')
-rw-r--r-- | java/net/DatagramSocket.java | 7 | ||||
-rw-r--r-- | java/net/ServerSocket.java | 12 | ||||
-rw-r--r-- | java/net/Socket.java | 10 | ||||
-rw-r--r-- | java/nio/channels/spi/AbstractSelectableChannel.java | 9 |
4 files changed, 28 insertions, 10 deletions
diff --git a/java/net/DatagramSocket.java b/java/net/DatagramSocket.java index c9c0f5d0f..c5920a094 100644 --- a/java/net/DatagramSocket.java +++ b/java/net/DatagramSocket.java @@ -39,6 +39,7 @@ exception statement from your version. */ package java.net; import gnu.java.net.PlainDatagramSocketImpl; +import gnu.java.nio.DatagramChannelImpl; import java.io.IOException; import java.nio.channels.DatagramChannel; import java.nio.channels.IllegalBlockingModeException; @@ -565,7 +566,8 @@ public class DatagramSocket ("Socket connected to a multicast address my not receive"); if (getChannel() != null - && !getChannel().isBlocking ()) + && !getChannel().isBlocking () + && !((DatagramChannelImpl) getChannel()).isInChannelOperation()) throw new IllegalBlockingModeException (); getImpl().receive(p); @@ -618,7 +620,8 @@ public class DatagramSocket // use getTimeToLive for TTL val. if (getChannel() != null - && !getChannel().isBlocking ()) + && !getChannel().isBlocking () + && !((DatagramChannelImpl) getChannel()).isInChannelOperation()) throw new IllegalBlockingModeException (); getImpl().send(p); diff --git a/java/net/ServerSocket.java b/java/net/ServerSocket.java index 9a2d82d9c..a53ebf674 100644 --- a/java/net/ServerSocket.java +++ b/java/net/ServerSocket.java @@ -1,5 +1,6 @@ /* ServerSocket.java -- Class for implementing server side sockets - Copyright (C) 1998, 1999, 2000, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004 + Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -345,9 +346,14 @@ public class ServerSocket if (isClosed()) throw new SocketException("ServerSocket is closed"); + // The Sun spec says that if we have an associated channel and + // it is in non-blocking mode, we throw an IllegalBlockingModeException. + // However, in our implementation if the channel itself initiated this + // operation, then we must honor it regardless of its blocking mode. if (getChannel() != null - && !getChannel().isBlocking()) - throw new IllegalBlockingModeException(); + && !getChannel().isBlocking () + && !((PlainSocketImpl) getImpl()).isInChannelOperation()) + throw new IllegalBlockingModeException (); impl.accept(socket.getImpl()); } diff --git a/java/net/Socket.java b/java/net/Socket.java index 9322e929e..f9cbb7e6c 100644 --- a/java/net/Socket.java +++ b/java/net/Socket.java @@ -1,5 +1,6 @@ /* Socket.java -- Client socket implementation - Copyright (C) 1998, 1999, 2000, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004 + Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -420,8 +421,13 @@ public class Socket if (! (endpoint instanceof InetSocketAddress)) throw new IllegalArgumentException("unsupported address type"); + // The Sun spec says that if we have an associated channel and + // it is in non-blocking mode, we throw an IllegalBlockingModeException. + // However, in our implementation if the channel itself initiated this + // operation, then we must honor it regardless of its blocking mode. if (getChannel() != null - && !getChannel().isBlocking ()) + && !getChannel().isBlocking () + && !((PlainSocketImpl) getImpl()).isInChannelOperation()) throw new IllegalBlockingModeException (); if (!isBound ()) diff --git a/java/nio/channels/spi/AbstractSelectableChannel.java b/java/nio/channels/spi/AbstractSelectableChannel.java index 17d6a2eae..76c6c2b89 100644 --- a/java/nio/channels/spi/AbstractSelectableChannel.java +++ b/java/nio/channels/spi/AbstractSelectableChannel.java @@ -1,5 +1,5 @@ /* AbstractSelectableChannel.java - Copyright (C) 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -80,8 +80,11 @@ public abstract class AbstractSelectableChannel extends SelectableChannel { synchronized (blockingLock()) { - implConfigureBlocking(blocking); - this.blocking = blocking; + if (this.blocking != blocking) + { + implConfigureBlocking(blocking); + this.blocking = blocking; + } } return this; |