diff options
author | Mark Wielaard <mark@klomp.org> | 2006-08-07 22:23:00 +0000 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2006-08-07 22:23:00 +0000 |
commit | 4366b4849b3ed205e3688304721473a8df8e4bb7 (patch) | |
tree | 0f0b28ce21de2cc0b7c0d402065c5c717331a0d0 | |
parent | 8e44dc1fa015c1e58adce96dea2793c46f9bb218 (diff) | |
download | classpath-4366b4849b3ed205e3688304721473a8df8e4bb7.tar.gz |
2006-08-07 Tom Tromey <tromey@redhat.com>
PR libgcj/23682:
* java/nio/channels/SelectionKey.java (attach): Now synchronized.
(attachment): Likewise.
* java/nio/channels/spi/AbstractSelectionKey.java (cancel): Now
synchronized.
(isValid): Likewise.
* gnu/java/nio/SelectionKeyImpl.java (impl): Now final
(ch): Likewise.
(interestOps): Synchronize.
(readyOps): Likewise.
* gnu/java/nio/SelectorImpl.java (register): Synchronize around
interestOps call.
-rw-r--r-- | ChangeLog | 15 | ||||
-rw-r--r-- | gnu/java/nio/SelectionKeyImpl.java | 22 | ||||
-rw-r--r-- | gnu/java/nio/SelectorImpl.java | 7 | ||||
-rw-r--r-- | java/nio/channels/SelectionKey.java | 6 | ||||
-rw-r--r-- | java/nio/channels/spi/AbstractSelectionKey.java | 6 |
5 files changed, 39 insertions, 17 deletions
@@ -1,3 +1,18 @@ +2006-08-07 Tom Tromey <tromey@redhat.com> + + PR libgcj/23682: + * java/nio/channels/SelectionKey.java (attach): Now synchronized. + (attachment): Likewise. + * java/nio/channels/spi/AbstractSelectionKey.java (cancel): Now + synchronized. + (isValid): Likewise. + * gnu/java/nio/SelectionKeyImpl.java (impl): Now final + (ch): Likewise. + (interestOps): Synchronize. + (readyOps): Likewise. + * gnu/java/nio/SelectorImpl.java (register): Synchronize around + interestOps call. + 2006-08-07 C. Scott Marshall <csm@gnu.org> Fixes PR 28608. diff --git a/gnu/java/nio/SelectionKeyImpl.java b/gnu/java/nio/SelectionKeyImpl.java index a1f125e9f..8745377c5 100644 --- a/gnu/java/nio/SelectionKeyImpl.java +++ b/gnu/java/nio/SelectionKeyImpl.java @@ -1,5 +1,5 @@ /* SelectionKeyImpl.java -- - Copyright (C) 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -47,8 +47,8 @@ public abstract class SelectionKeyImpl extends AbstractSelectionKey { private int readyOps; private int interestOps; - private SelectorImpl impl; - SelectableChannel ch; + private final SelectorImpl impl; + final SelectableChannel ch; public SelectionKeyImpl (SelectableChannel ch, SelectorImpl impl) { @@ -61,7 +61,7 @@ public abstract class SelectionKeyImpl extends AbstractSelectionKey return ch; } - public int readyOps () + public synchronized int readyOps () { if (!isValid()) throw new CancelledKeyException(); @@ -69,7 +69,7 @@ public abstract class SelectionKeyImpl extends AbstractSelectionKey return readyOps; } - public SelectionKey readyOps (int ops) + public synchronized SelectionKey readyOps (int ops) { if (!isValid()) throw new CancelledKeyException(); @@ -83,15 +83,21 @@ public abstract class SelectionKeyImpl extends AbstractSelectionKey if (!isValid()) throw new CancelledKeyException(); - return interestOps; + synchronized (impl.selectedKeys()) + { + return interestOps; + } } public SelectionKey interestOps (int ops) { if (!isValid()) throw new CancelledKeyException(); - - interestOps = ops; + + synchronized (impl.selectedKeys()) + { + interestOps = ops; + } return this; } diff --git a/gnu/java/nio/SelectorImpl.java b/gnu/java/nio/SelectorImpl.java index ecfb5e7dc..c08478c99 100644 --- a/gnu/java/nio/SelectorImpl.java +++ b/gnu/java/nio/SelectorImpl.java @@ -1,5 +1,5 @@ /* SelectorImpl.java -- - Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -387,10 +387,11 @@ public class SelectorImpl extends AbstractSelector synchronized (keys) { keys.add (result); + + result.interestOps (ops); + result.attach (att); } - result.interestOps (ops); - result.attach (att); return result; } } diff --git a/java/nio/channels/SelectionKey.java b/java/nio/channels/SelectionKey.java index 5219b6bff..9723faf52 100644 --- a/java/nio/channels/SelectionKey.java +++ b/java/nio/channels/SelectionKey.java @@ -1,5 +1,5 @@ /* SelectionKey.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -60,7 +60,7 @@ public abstract class SelectionKey /** * Attaches obj to the key and returns the old attached object. */ - public final Object attach(Object obj) + public final synchronized Object attach(Object obj) { Object old = attached; attached = obj; @@ -70,7 +70,7 @@ public abstract class SelectionKey /** * Returns the object attached to the key. */ - public final Object attachment() + public final synchronized Object attachment() { return attached; } diff --git a/java/nio/channels/spi/AbstractSelectionKey.java b/java/nio/channels/spi/AbstractSelectionKey.java index 5ab8468bf..02d09ce10 100644 --- a/java/nio/channels/spi/AbstractSelectionKey.java +++ b/java/nio/channels/spi/AbstractSelectionKey.java @@ -1,5 +1,5 @@ /* AbstractSelectionKey.java -- - Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -57,7 +57,7 @@ public abstract class AbstractSelectionKey extends SelectionKey /** * Cancels this key. */ - public final void cancel() + public final synchronized void cancel() { if (isValid()) { @@ -71,7 +71,7 @@ public abstract class AbstractSelectionKey extends SelectionKey * * @return true if this key is valid, false otherwise */ - public final boolean isValid() + public final synchronized boolean isValid() { return ! cancelled; } |