mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8282726: java/net/vthread/BlockingSocketOps.java timeout/hang intermittently on Windows
Reviewed-by: djelinski
This commit is contained in:
parent
923207073a
commit
21a59b9f4e
8 changed files with 31 additions and 33 deletions
|
@ -94,14 +94,16 @@ abstract class Poller {
|
|||
}
|
||||
|
||||
/**
|
||||
* Register the file descriptor.
|
||||
* Register the file descriptor. The registration is "one shot", meaning it should
|
||||
* be polled at most once.
|
||||
*/
|
||||
abstract void implRegister(int fdVal) throws IOException;
|
||||
|
||||
/**
|
||||
* Deregister the file descriptor.
|
||||
* @param polled true if the file descriptor has already been polled
|
||||
*/
|
||||
abstract void implDeregister(int fdVal);
|
||||
abstract void implDeregister(int fdVal, boolean polled);
|
||||
|
||||
/**
|
||||
* Poll for events. The {@link #polled(int)} method is invoked for each
|
||||
|
@ -182,23 +184,23 @@ abstract class Poller {
|
|||
}
|
||||
|
||||
/**
|
||||
* Registers the file descriptor.
|
||||
* Registers the file descriptor to be polled at most once when the file descriptor
|
||||
* is ready for I/O.
|
||||
*/
|
||||
private void register(int fdVal) throws IOException {
|
||||
Thread previous = map.putIfAbsent(fdVal, Thread.currentThread());
|
||||
Thread previous = map.put(fdVal, Thread.currentThread());
|
||||
assert previous == null;
|
||||
implRegister(fdVal);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deregister the file descriptor, a no-op if already polled.
|
||||
* Deregister the file descriptor so that the file descriptor is not polled.
|
||||
*/
|
||||
private void deregister(int fdVal) {
|
||||
Thread previous = map.remove(fdVal);
|
||||
assert previous == null || previous == Thread.currentThread();
|
||||
if (previous != null) {
|
||||
implDeregister(fdVal);
|
||||
}
|
||||
boolean polled = (previous == null);
|
||||
assert polled || previous == Thread.currentThread();
|
||||
implDeregister(fdVal, polled);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue