summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
Diffstat (limited to 'gnu')
-rw-r--r--gnu/java/nio/SelectionKeyImpl.java22
-rw-r--r--gnu/java/nio/SelectorImpl.java7
2 files changed, 18 insertions, 11 deletions
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;
}
}