Skip to content

Commit

Permalink
When cancelling a SelectionKey, remove it from the selected key set. F…
Browse files Browse the repository at this point in the history
…ixes jruby/jruby#398, and possibly jruby/jruby#334.
  • Loading branch information
vp-of-awesome committed Nov 17, 2012
1 parent 1936e05 commit 79639b1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main/java/jnr/enxio/channels/KQSelector.java
Expand Up @@ -162,6 +162,9 @@ private int poll(long timeout) {
KQSelectionKey kqs = (KQSelectionKey) k;
Descriptor d = descriptors.get(kqs.getFD());
deregister(kqs);
synchronized (selected) {
selected.remove(kqs);
}
d.keys.remove(kqs);
if (d.keys.isEmpty()) {
io.put(changebuf, nchanged++, kqs.getFD(), EVFILT_READ, EV_DELETE);
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/jnr/enxio/channels/PollSelector.java
Expand Up @@ -179,6 +179,9 @@ private void remove(PollSelectionKey k) {
}
keyArray[nfds - 1] = null;
--nfds;
synchronized (selected) {
selected.remove(k);
}
keys.remove(k);
}
deregister(k);
Expand Down

0 comments on commit 79639b1

Please sign in to comment.