8000 Revert "Fix concurrency issue from modifying the selectedKeysSet" · kohlschutter/junixsocket@4b2bfc8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4b2bfc8

Browse files
committed
Revert "Fix concurrency issue from modifying the selectedKeysSet"
This reverts commit b8386a1.
1 parent f0bafd4 commit 4b2bfc8

File tree

2 files changed

+2
-23
lines changed

2 files changed

+2
-23
lines changed

junixsocket-common/src/main/java/org/newsclub/net/unix/AFSelectionKey.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,8 @@ boolean isSelected() {
8080

8181
@Override
8282
public void cancel() {
83-
if (!cancelled.compareAndSet(false, true) || !chann.isOpen()) {
84-
return;
85-
}
86-
sel.prepareRemove(this);
83+
sel.remove(this);
84+
cancelNoRemove();
8785
}
8886

8987
void cancelNoRemove() {

junixsocket-common/src/main/java/org/newsclub/net/unix/AFSelector.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ final class AFSelector extends AbstractSelector {
4949

5050
private final Set<SelectionKey> selectedKeysSet = new HashSet<>();
5151
private final Set<SelectionKey> selectedKeysPublic = new UngrowableSet<>(selectedKeysSet);
52-
private final Set<SelectionKey> cancelledKeysSet = new HashSet<>();
5352

5453
private PollFd pollFd = null;
5554

@@ -113,7 +112,6 @@ private int select0(int timeout) throws IOException {
113112
throw new ClosedSelectorException();
114113
}
115114
pfd = pollFd = initPollFd(pollFd);
116-
performRemove();
117115
selectedKeysSet.clear();
118116
}
119117
int num;
@@ -301,23 +299,6 @@ synchronized void remove(AFSelectionKey key) {
301299
pollFd = null;
302300
}
303301

304-
void prepareRemove(AFSelectionKey key) {
305-
synchronized (cancelledKeysSet) {
306-
cancelledKeysSet.add(key);
307-
}
308-
}
309-
310-
void performRemove() {
311-
synchronized (cancelledKeysSet) {
312-
for (SelectionKey key : cancelledKeysSet) {
313-
selectedKeysSet.remove(key);
314-
deregister((AFSelectionKey) key);
315-
pollFd = null;
316-
}
317-
cancelledKeysSet.clear();
318-
}
319-
}
320-
321302
private void deregister(AFSelectionKey key) {
322303
// super.deregister unnecessarily casts SelectionKey to AbstractSelectionKey, and
323304
// ((AbstractSelectableChannel)key.channel()).removeKey(key); is not visible.

0 commit comments

Comments
 (0)
0