changeset in /hg/icedtea6: Fix UNIX sun.nio.ch and shared sun.ni...
Andrew John Hughes
gnu_andrew at member.fsf.org
Tue Feb 3 04:13:58 PST 2009
changeset 913512a256bd in /hg/icedtea6
details: http://icedtea.classpath.org/hg/icedtea6?cmd=changeset;node=913512a256bd
description:
Fix UNIX sun.nio.ch and shared sun.nio.fs classes.
2009-01-19 Andrew John Hughes <gnu_andrew at member.fsf.org>
* overlays/nio2/openjdk/jdk/src/share/classes/org/classpath/icedtea/misc/JavaNetGetIndexAccess.java:
(getByIndex(int)): New method.
* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/AsynchronousServerSocketChannelImpl.java:
Fixed imports.
* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/MembershipKeyImpl.java,
* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/MembershipRegistry.java:
New files.
* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/SimpleAsynchronousFileChannelImpl.java:
Fix imports, refer to AsynchronousFileLockImpl instead of FileLockImpl.
* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractAclFileAttributeView.java:
Fix imports and vararg usage.
* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractBasicFileAttributeView.java,
* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractFileStoreSpaceAttributeView.java:
Fix vararg usage.
* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractPoller.java,
* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractWatchKey.java,
* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractWatchService.java:
Fix imports.
* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/FileOwnerAttributeViewImpl.java:
Fix imports and vararg usage.
* overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/EPollPort.java,
* overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/LinuxAsynchronousChannelProvider.java,
* overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/Port.java,
* overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java,
* overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java:
Fix imports.
* patches/icedtea-nio2.patch:
Add new classes.
(Unsafe.copyMemory(long,long,long)): Backported.
(Unsafe.copyMemory(Object,long,Object,long,long)): Backported.
(Unsafe.ARRAY_BYTE_BASE_OFFSET): Likewise.
(DatagramChannelImpl.bind(SocketAddress)): Likewise.
(DatagramChannelImpl.getLocalAddress()): Likewise.
(DatagramChannelImpl.getOption(SocketOption)): Likewise.
(DatagramChannelImpl.innerJoin(InetAddress,NetworkInterface,InetAddress)): Likewise.
(DatagramChannelImpl.join(InetAddress,NetworkInterface)): Likewise.
(DatagramChannelImpl.join(InetAddress,NetworkInterface,InetAddress)): Likewise.
(DatagramChannelImpl.block(MembershipKeyImpl,InetAddress)): Likewise.
(DatagramChannelImpl.unblock(MembershipKeyImpl,InetAddress)): Likewise.
(DatagramChannelImpl.drop(MembershipKeyImpl)): Likewise.
(Net.getInterface4(FileDescriptor)): Likewise.
(Net.getInterface6(FileDescriptor)): Likewise.
(Net.inet4FromInt(int)): Likewise.
(Net.inet6AsByteArray(InetAddress)): Likewise.
(Net.join6(FileDescriptor,byte[],int,byte[])): Likewise.
(Net.drop6(FileDescriptor,byte[],int,byte[])): Likewise.
(Net.joinOrDrop6(boolean,FileDescriptor,byte[],int,byte[])): Likewise.
(Net.block6(FileDescriptor,byte[],int,byte[])): Likewise.
(Net.unblock6(FileDescriptor,byte[],int,byte[])): Likewise.
(Net.blockOrUnblock6(boolean,FileDescriptor,byte[],int,byte[])): Likewise.
(Net.join4(FileDescriptor,int,int,int)): Likewise.
(Net.drop4(FileDescriptor,int,int,int)): Likewise.
(Net.joinOrDrop4(boolean,FileDescriptor,int,int,int)): Likewise.
(Net.block4(FileDescriptor,int,int,int)): Likewise.
(Net.unblock4(FileDescriptor,int,int,int)): Likewise.
(Net.blockOrUnblock4(boolean,FileDescriptor,int,int,int)): Likewise.
(Net.connect(FileDescriptor,InetAddress,int)): Likewise.
(Net.connect(ProtocolFamily,FileDescriptor,InetAddress,int)): Likewise.
(Net.connect0(boolean,FileDescriptor,InetAddress,int)): Likewise.
(FileDispatcher.NO_LOCK)): Likewise.
(FileDispatcher.LOCKED)): Likewise.
(FileDispatcher.RET_EX_LOCK)): Likewise.
(FileDispatcher.INTERRUPTED)): Likewise.
(FileDispatcher.size(FileDescriptor)): Likewise.
(FileDispatcher.truncate(FileDescriptor, long)): Likewise.
(FileDispatcher.force(FileDescriptor, boolean)): Likewise.
(FileDispatcher.lock(FileDescriptor, boolean, long, long, boolean)): Likewise.
(FileDispatcher.release(FileDescriptor, long, long)): Likewise.
(FileDispatcher.force0(FileDescriptor,boolean)): Likewise.
(FileDispatcher.truncate0(FileDescriptor, long)): Likewise.
(FileDispatcher.size0(FileDescriptor)): Likewise.
(FileDispatcher.lock0(FileDescriptor, boolean, long, long, boolean)): Likewise.
(FileDispatcher.release0(FileDescriptor, long, long)): Likewise.
diffstat:
19 files changed, 1133 insertions(+), 31 deletions(-)
ChangeLog | 76 +
overlays/nio2/openjdk/jdk/src/share/classes/org/classpath/icedtea/misc/JavaNetGetIndexAccess.java | 1
overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/AsynchronousServerSocketChannelImpl.java | 2
overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/MembershipKeyImpl.java | 224 +++
overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/MembershipRegistry.java | 132 ++
overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/SimpleAsynchronousFileChannelImpl.java | 18
overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractAclFileAttributeView.java | 3
overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractBasicFileAttributeView.java | 2
overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractFileStoreSpaceAttributeView.java | 2
overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractPoller.java | 8
overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractWatchKey.java | 1
overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractWatchService.java | 3
overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/FileOwnerAttributeViewImpl.java | 6
overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/EPollPort.java | 3
overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/LinuxAsynchronousChannelProvider.java | 7
overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/Port.java | 7
overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java | 8
overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java | 9
patches/icedtea-nio2.patch | 652 +++++++++-
diffs (truncated from 1562 to 500 lines):
diff -r fb3c68368b7f -r 913512a256bd ChangeLog
--- a/ChangeLog Mon Jan 19 14:25:02 2009 +0000
+++ b/ChangeLog Tue Jan 20 00:06:18 2009 +0000
@@ -1,3 +1,79 @@ 2009-01-19 Andrew John Hughes <gnu_and
+2009-01-19 Andrew John Hughes <gnu_andrew at member.fsf.org>
+
+ * overlays/nio2/openjdk/jdk/src/share/classes/org/classpath/icedtea/misc/JavaNetGetIndexAccess.java:
+ (getByIndex(int)): New method.
+ * overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/AsynchronousServerSocketChannelImpl.java:
+ Fixed imports.
+ * overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/MembershipKeyImpl.java,
+ * overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/MembershipRegistry.java:
+ New files.
+ * overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/SimpleAsynchronousFileChannelImpl.java:
+ Fix imports, refer to AsynchronousFileLockImpl instead of FileLockImpl.
+ * overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractAclFileAttributeView.java:
+ Fix imports and vararg usage.
+ * overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractBasicFileAttributeView.java,
+ * overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractFileStoreSpaceAttributeView.java:
+ Fix vararg usage.
+ * overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractPoller.java,
+ * overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractWatchKey.java,
+ * overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractWatchService.java:
+ Fix imports.
+ * overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/FileOwnerAttributeViewImpl.java:
+ Fix imports and vararg usage.
+ * overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/EPollPort.java,
+ * overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/LinuxAsynchronousChannelProvider.java,
+ * overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/Port.java,
+ * overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java,
+ * overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java:
+ Fix imports.
+ * patches/icedtea-nio2.patch:
+ Add new classes.
+ (Unsafe.copyMemory(long,long,long)): Backported.
+ (Unsafe.copyMemory(Object,long,Object,long,long)): Backported.
+ (Unsafe.ARRAY_BYTE_BASE_OFFSET): Likewise.
+ (DatagramChannelImpl.bind(SocketAddress)): Likewise.
+ (DatagramChannelImpl.getLocalAddress()): Likewise.
+ (DatagramChannelImpl.getOption(SocketOption)): Likewise.
+ (DatagramChannelImpl.innerJoin(InetAddress,NetworkInterface,InetAddress)): Likewise.
+ (DatagramChannelImpl.join(InetAddress,NetworkInterface)): Likewise.
+ (DatagramChannelImpl.join(InetAddress,NetworkInterface,InetAddress)): Likewise.
+ (DatagramChannelImpl.block(MembershipKeyImpl,InetAddress)): Likewise.
+ (DatagramChannelImpl.unblock(MembershipKeyImpl,InetAddress)): Likewise.
+ (DatagramChannelImpl.drop(MembershipKeyImpl)): Likewise.
+ (Net.getInterface4(FileDescriptor)): Likewise.
+ (Net.getInterface6(FileDescriptor)): Likewise.
+ (Net.inet4FromInt(int)): Likewise.
+ (Net.inet6AsByteArray(InetAddress)): Likewise.
+ (Net.join6(FileDescriptor,byte[],int,byte[])): Likewise.
+ (Net.drop6(FileDescriptor,byte[],int,byte[])): Likewise.
+ (Net.joinOrDrop6(boolean,FileDescriptor,byte[],int,byte[])): Likewise.
+ (Net.block6(FileDescriptor,byte[],int,byte[])): Likewise.
+ (Net.unblock6(FileDescriptor,byte[],int,byte[])): Likewise.
+ (Net.blockOrUnblock6(boolean,FileDescriptor,byte[],int,byte[])): Likewise.
+ (Net.join4(FileDescriptor,int,int,int)): Likewise.
+ (Net.drop4(FileDescriptor,int,int,int)): Likewise.
+ (Net.joinOrDrop4(boolean,FileDescriptor,int,int,int)): Likewise.
+ (Net.block4(FileDescriptor,int,int,int)): Likewise.
+ (Net.unblock4(FileDescriptor,int,int,int)): Likewise.
+ (Net.blockOrUnblock4(boolean,FileDescriptor,int,int,int)): Likewise.
+ (Net.connect(FileDescriptor,InetAddress,int)): Likewise.
+ (Net.connect(ProtocolFamily,FileDescriptor,InetAddress,int)): Likewise.
+ (Net.connect0(boolean,FileDescriptor,InetAddress,int)): Likewise.
+ (FileDispatcher.NO_LOCK)): Likewise.
+ (FileDispatcher.LOCKED)): Likewise.
+ (FileDispatcher.RET_EX_LOCK)): Likewise.
+ (FileDispatcher.INTERRUPTED)): Likewise.
+ (FileDispatcher.size(FileDescriptor)): Likewise.
+ (FileDispatcher.truncate(FileDescriptor, long)): Likewise.
+ (FileDispatcher.force(FileDescriptor, boolean)): Likewise.
+ (FileDispatcher.lock(FileDescriptor, boolean, long, long, boolean)): Likewise.
+ (FileDispatcher.release(FileDescriptor, long, long)): Likewise.
+ (FileDispatcher.force0(FileDescriptor,boolean)): Likewise.
+ (FileDispatcher.truncate0(FileDescriptor, long)): Likewise.
+ (FileDispatcher.size0(FileDescriptor)): Likewise.
+ (FileDispatcher.lock0(FileDescriptor, boolean, long, long, boolean)): Likewise.
+ (FileDispatcher.release0(FileDescriptor, long, long)): Likewise.
+
2009-01-19 Andrew John Hughes <gnu_andrew at member.fsf.org>
* generated/sun/nio/ch/SocketOptionRegistry.java:
diff -r fb3c68368b7f -r 913512a256bd overlays/nio2/openjdk/jdk/src/share/classes/org/classpath/icedtea/misc/JavaNetGetIndexAccess.java
--- a/overlays/nio2/openjdk/jdk/src/share/classes/org/classpath/icedtea/misc/JavaNetGetIndexAccess.java Mon Jan 19 14:25:02 2009 +0000
+++ b/overlays/nio2/openjdk/jdk/src/share/classes/org/classpath/icedtea/misc/JavaNetGetIndexAccess.java Tue Jan 20 00:06:18 2009 +0000
@@ -42,4 +42,5 @@ public interface JavaNetGetIndexAccess
public interface JavaNetGetIndexAccess
{
int getIndex(NetworkInterface nf);
+ NetworkInterface getByIndex(int i);
}
diff -r fb3c68368b7f -r 913512a256bd overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/AsynchronousServerSocketChannelImpl.java
--- a/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/AsynchronousServerSocketChannelImpl.java Mon Jan 19 14:25:02 2009 +0000
+++ b/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/AsynchronousServerSocketChannelImpl.java Tue Jan 20 00:06:18 2009 +0000
@@ -25,11 +25,11 @@
package sun.nio.ch;
-import java.nio.channels.*;
import java.net.SocketAddress;
import java.net.InetSocketAddress;
import java.io.FileDescriptor;
import java.io.IOException;
+import java.nio.channels.ClosedChannelException;
import java.util.Set;
import java.util.HashSet;
import java.util.Collections;
diff -r fb3c68368b7f -r 913512a256bd overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/MembershipKeyImpl.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/MembershipKeyImpl.java Tue Jan 20 00:06:18 2009 +0000
@@ -0,0 +1,224 @@
+/*
+ * Copyright 2007-2008 Sun Microsystems, Inc. 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. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package sun.nio.ch;
+
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.io.IOException;
+import java.util.HashSet;
+
+import org.classpath.icedtea.java.nio.channels.MembershipKey;
+import org.classpath.icedtea.java.nio.channels.MulticastChannel;
+
+/**
+ * MembershipKey implementation.
+ */
+
+class MembershipKeyImpl
+ extends MembershipKey
+{
+ private final MulticastChannel ch;
+ private final InetAddress group;
+ private final NetworkInterface interf;
+ private final InetAddress source;
+
+ // true when key is valid
+ private volatile boolean valid = true;
+
+ // lock used when creating or accessing blockedSet
+ private Object stateLock = new Object();
+
+ // set of source addresses that are blocked
+ private HashSet<InetAddress> blockedSet;
+
+ private MembershipKeyImpl(MulticastChannel ch,
+ InetAddress group,
+ NetworkInterface interf,
+ InetAddress source)
+ {
+ this.ch = ch;
+ this.group = group;
+ this.interf = interf;
+ this.source = source;
+ }
+
+ /**
+ * MembershipKey will additional context for IPv4 membership
+ */
+ static class Type4 extends MembershipKeyImpl {
+ private final int groupAddress;
+ private final int interfAddress;
+ private final int sourceAddress;
+
+ Type4(MulticastChannel ch,
+ InetAddress group,
+ NetworkInterface interf,
+ InetAddress source,
+ int groupAddress,
+ int interfAddress,
+ int sourceAddress)
+ {
+ super(ch, group, interf, source);
+ this.groupAddress = groupAddress;
+ this.interfAddress = interfAddress;
+ this.sourceAddress = sourceAddress;
+ }
+
+ int groupAddress() {
+ return groupAddress;
+ }
+
+ int interfaceAddress() {
+ return interfAddress;
+ }
+
+ int source() {
+ return sourceAddress;
+ }
+ }
+
+ /**
+ * MembershipKey will additional context for IPv6 membership
+ */
+ static class Type6 extends MembershipKeyImpl {
+ private final byte[] groupAddress;
+ private final int index;
+ private final byte[] sourceAddress;
+
+ Type6(MulticastChannel ch,
+ InetAddress group,
+ NetworkInterface interf,
+ InetAddress source,
+ byte[] groupAddress,
+ int index,
+ byte[] sourceAddress)
+ {
+ super(ch, group, interf, source);
+ this.groupAddress = groupAddress;
+ this.index = index;
+ this.sourceAddress = sourceAddress;
+ }
+
+ byte[] groupAddress() {
+ return groupAddress;
+ }
+
+ int index() {
+ return index;
+ }
+
+ byte[] source() {
+ return sourceAddress;
+ }
+ }
+
+ public boolean isValid() {
+ return valid;
+ }
+
+ // package-private
+ void invalidate() {
+ valid = false;
+ }
+
+ public void drop() throws IOException {
+ // delegate to channel
+ ((DatagramChannelImpl)ch).drop(this);
+ }
+
+
+ public MulticastChannel channel() {
+ return ch;
+ }
+
+
+ public InetAddress group() {
+ return group;
+ }
+
+
+ public NetworkInterface networkInterface() {
+ return interf;
+ }
+
+
+ public InetAddress sourceAddress() {
+ return source;
+ }
+
+
+ public MembershipKey block(InetAddress toBlock)
+ throws IOException
+ {
+ if (source != null)
+ throw new IllegalStateException("key is source-specific");
+
+ synchronized (stateLock) {
+ if ((blockedSet != null) && blockedSet.contains(toBlock)) {
+ // already blocked, nothing to do
+ return this;
+ }
+
+ ((DatagramChannelImpl)ch).block(this, toBlock);
+
+ // created blocked set if required and add source address
+ if (blockedSet == null)
+ blockedSet = new HashSet<InetAddress>();
+ blockedSet.add(toBlock);
+ }
+ return this;
+ }
+
+
+ public MembershipKey unblock(InetAddress toUnblock)
+ throws IOException
+ {
+ synchronized (stateLock) {
+ if ((blockedSet == null) || !blockedSet.contains(toUnblock))
+ throw new IllegalStateException("not blocked");
+
+ ((DatagramChannelImpl)ch).unblock(this, toUnblock);
+
+ blockedSet.remove(toUnblock);
+ }
+ return this;
+ }
+
+
+ public String toString() {
+ StringBuilder sb = new StringBuilder(64);
+ sb.append('<');
+ sb.append(group.getHostAddress());
+ sb.append(',');
+ sb.append(interf.getName());
+ if (source != null) {
+ sb.append(',');
+ sb.append(source.getHostAddress());
+ }
+ sb.append('>');
+ return sb.toString();
+ }
+}
diff -r fb3c68368b7f -r 913512a256bd overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/MembershipRegistry.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/MembershipRegistry.java Tue Jan 20 00:06:18 2009 +0000
@@ -0,0 +1,132 @@
+/*
+ * Copyright 2007-2008 Sun Microsystems, Inc. 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. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package sun.nio.ch;
+
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.util.*;
+
+import org.classpath.icedtea.java.nio.channels.MembershipKey;
+
+/**
+ * Simple registry of membership keys for a MulticastChannel.
+ *
+ * Instances of this object are not safe by multiple concurrent threads.
+ */
+
+class MembershipRegistry {
+
+ // map multicast group to keys
+ private Map<InetAddress,List<MembershipKeyImpl>> groups = null;
+
+ MembershipRegistry() {
+ }
+
+ /**
+ * Checks registry for membership of the group on the given
+ * network interface.
+ */
+ MembershipKey checkMembership(InetAddress group, NetworkInterface interf,
+ InetAddress source)
+ {
+ if (groups != null) {
+ List<MembershipKeyImpl> keys = groups.get(group);
+ if (keys != null) {
+ for (MembershipKeyImpl key: keys) {
+ if (key.networkInterface().equals(interf)) {
+ // already a member to receive all packets so return
+ // existing key or detect conflict
+ if (source == null) {
+ if (key.sourceAddress() == null)
+ return key;
+ throw new IllegalStateException("Already a member to receive all packets");
+ }
+
+ // already have source-specific membership so return key
+ // or detect conflict
+ if (key.sourceAddress() == null)
+ throw new IllegalStateException("Already have source-specific membership");
+ if (source.equals(key.sourceAddress()))
+ return key;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Add membership to the registry, returning a new membership key.
+ */
+ void add(MembershipKeyImpl key) {
+ InetAddress group = key.group();
+ List<MembershipKeyImpl> keys;
+ if (groups == null) {
+ groups = new HashMap<InetAddress,List<MembershipKeyImpl>>();
+ keys = null;
+ } else {
+ keys = groups.get(group);
+ }
+ if (keys == null) {
+ keys = new LinkedList<MembershipKeyImpl>();
+ groups.put(group, keys);
+ }
+ keys.add(key);
+ }
+
+ /**
+ * Remove a key from the registry
+ */
+ void remove(MembershipKeyImpl key) {
+ InetAddress group = key.group();
+ List<MembershipKeyImpl> keys = groups.get(group);
+ if (keys != null) {
+ Iterator<MembershipKeyImpl> i = keys.iterator();
+ while (i.hasNext()) {
+ if (i.next() == key) {
+ i.remove();
+ break;
+ }
+ }
+ if (keys.isEmpty()) {
+ groups.remove(group);
+ }
+ }
+ }
+
+ /**
+ * Invalidate all keys in the registry
+ */
+ void invalidateAll() {
+ if (groups != null) {
+ for (InetAddress group: groups.keySet()) {
+ for (MembershipKeyImpl key: groups.get(group)) {
+ key.invalidate();
+ }
+ }
+ }
+ }
+}
diff -r fb3c68368b7f -r 913512a256bd overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/SimpleAsynchronousFileChannelImpl.java
--- a/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/SimpleAsynchronousFileChannelImpl.java Mon Jan 19 14:25:02 2009 +0000
+++ b/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/SimpleAsynchronousFileChannelImpl.java Tue Jan 20 00:06:18 2009 +0000
@@ -25,13 +25,21 @@
package sun.nio.ch;
-import java.nio.channels.*;
import java.util.concurrent.*;
import java.nio.ByteBuffer;
+import java.nio.channels.AsynchronousCloseException;
+import java.nio.channels.ClosedChannelException;
+import java.nio.channels.NonReadableChannelException;
+import java.nio.channels.NonWritableChannelException;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.io.FileDescriptor;
import java.io.IOException;
+
+import org.classpath.icedtea.java.nio.channels.AsynchronousFileChannel;
+import org.classpath.icedtea.java.nio.channels.CompletionHandler;
+import org.classpath.icedtea.java.nio.channels.FileLock;
+import org.classpath.icedtea.java.nio.channels.ShutdownChannelGroupException;
/**
* "Portable" implementation of AsynchronousFileChannel for use on operating
@@ -60,7 +68,7 @@ public class SimpleAsynchronousFileChann
}
More information about the distro-pkg-dev
mailing list