File tree Expand file tree Collapse file tree 2 files changed +2
-23
lines changed
junixsocket-common/src/main/java/org/newsclub/net/unix Expand file tree Collapse file tree 2 files changed +2
-23
lines changed Original file line number Diff line number Diff line change @@ -80,10 +80,8 @@ boolean isSelected() {
80
80
81
81
@ Override
82
82
public void cancel () {
83
- if (!cancelled .compareAndSet (false , true ) || !chann .isOpen ()) {
84
- return ;
85
- }
86
- sel .prepareRemove (this );
83
+ sel .remove (this );
84
+ cancelNoRemove ();
87
85
}
88
86
89
87
void cancelNoRemove () {
Original file line number Diff line number Diff line change @@ -49,7 +49,6 @@ final class AFSelector extends AbstractSelector {
49
49
50
50
private final Set <SelectionKey > selectedKeysSet = new HashSet <>();
51
51
private final Set <SelectionKey > selectedKeysPublic = new UngrowableSet <>(selectedKeysSet );
52
- private final Set <SelectionKey > cancelledKeysSet = new HashSet <>();
53
52
54
53
private PollFd pollFd = null ;
55
54
@@ -113,7 +112,6 @@ private int select0(int timeout) throws IOException {
113
112
throw new ClosedSelectorException ();
114
113
}
115
114
pfd = pollFd = initPollFd (pollFd );
116
- performRemove ();
117
115
selectedKeysSet .clear ();
118
116
}
119
117
int num ;
@@ -301,23 +299,6 @@ synchronized void remove(AFSelectionKey key) {
301
299
pollFd = null ;
302
300
}
303
301
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
-
321
302
private void deregister (AFSelectionKey key ) {
322
303
// super.deregister unnecessarily casts SelectionKey to AbstractSelectionKey, and
323
304
// ((AbstractSelectableChannel)key.channel()).removeKey(key); is not visible.
You can’t perform that action at this time.
0 commit comments