mirror of
https://github.com/openjdk/jdk.git
synced 2026-05-30 23:33:14 +00:00
8024883: (se) SelectableChannel.register throws NPE if fd >= 64k (lnx)
Co-authored-by: Norman Maurer <nmaurer@redhat.com> Reviewed-by: alanb, coffeys
This commit is contained in:
parent
5ae304e238
commit
2785e7d00a
@ -26,9 +26,11 @@
|
||||
package sun.nio.ch;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.AccessController;
|
||||
import java.util.BitSet;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import sun.security.action.GetIntegerAction;
|
||||
|
||||
|
||||
/**
|
||||
@ -78,10 +80,11 @@ class DevPollArrayWrapper {
|
||||
static final int NUM_POLLFDS = Math.min(OPEN_MAX-1, 8192);
|
||||
|
||||
// Initial size of arrays for fd registration changes
|
||||
private final int INITIAL_PENDING_UPDATE_SIZE = 64;
|
||||
private static final int INITIAL_PENDING_UPDATE_SIZE = 64;
|
||||
|
||||
// maximum size of updatesLow
|
||||
private final int MAX_UPDATE_ARRAY_SIZE = Math.min(OPEN_MAX, 64*1024);
|
||||
private static final int MAX_UPDATE_ARRAY_SIZE = AccessController.doPrivileged(
|
||||
new GetIntegerAction("sun.nio.ch.maxUpdateArraySize", Math.min(OPEN_MAX, 64*1024)));
|
||||
|
||||
// The pollfd array for results from devpoll driver
|
||||
private final AllocatedNativeObject pollArray;
|
||||
|
||||
@ -26,9 +26,11 @@
|
||||
package sun.nio.ch;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.AccessController;
|
||||
import java.util.BitSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import sun.security.action.GetIntegerAction;
|
||||
|
||||
/**
|
||||
* Manipulates a native array of epoll_event structs on Linux:
|
||||
@ -78,8 +80,8 @@ class EPollArrayWrapper {
|
||||
private static final int INITIAL_PENDING_UPDATE_SIZE = 64;
|
||||
|
||||
// maximum size of updatesLow
|
||||
private static final int MAX_UPDATE_ARRAY_SIZE = Math.min(OPEN_MAX, 64*1024);
|
||||
|
||||
private static final int MAX_UPDATE_ARRAY_SIZE = AccessController.doPrivileged(
|
||||
new GetIntegerAction("sun.nio.ch.maxUpdateArraySize", Math.min(OPEN_MAX, 64*1024)));
|
||||
|
||||
// The fd of the epoll driver
|
||||
private final int epfd;
|
||||
@ -163,6 +165,16 @@ class EPollArrayWrapper {
|
||||
return pollArray.getInt(offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if updates for the given key (file
|
||||
* descriptor) are killed.
|
||||
*/
|
||||
private boolean isEventsHighKilled(Integer key) {
|
||||
assert key >= MAX_UPDATE_ARRAY_SIZE;
|
||||
Byte value = eventsHigh.get(key);
|
||||
return (value != null && value == KILLED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the pending update events for the given file descriptor. This
|
||||
* method has no effect if the update events is already set to KILLED,
|
||||
@ -175,7 +187,7 @@ class EPollArrayWrapper {
|
||||
}
|
||||
} else {
|
||||
Integer key = Integer.valueOf(fd);
|
||||
if ((eventsHigh.get(key) != KILLED) || force) {
|
||||
if (!isEventsHighKilled(key) || force) {
|
||||
eventsHigh.put(key, Byte.valueOf(events));
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,9 +25,14 @@
|
||||
|
||||
package sun.nio.ch;
|
||||
|
||||
import sun.misc.Unsafe;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.security.AccessController;
|
||||
import java.util.BitSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import sun.misc.Unsafe;
|
||||
import sun.security.action.GetIntegerAction;
|
||||
import static sun.nio.ch.SolarisEventPort.*;
|
||||
|
||||
/**
|
||||
@ -49,7 +54,8 @@ class EventPortWrapper {
|
||||
private final int INITIAL_PENDING_UPDATE_SIZE = 256;
|
||||
|
||||
// maximum size of updateArray
|
||||
private final int MAX_UPDATE_ARRAY_SIZE = Math.min(OPEN_MAX, 64*1024);
|
||||
private static final int MAX_UPDATE_ARRAY_SIZE = AccessController.doPrivileged(
|
||||
new GetIntegerAction("sun.nio.ch.maxUpdateArraySize", Math.min(OPEN_MAX, 64*1024)));
|
||||
|
||||
// special update status to indicate that it should be ignored
|
||||
private static final byte IGNORE = -1;
|
||||
|
||||
@ -22,9 +22,10 @@
|
||||
*/
|
||||
|
||||
/* @test
|
||||
* @bug 4503092
|
||||
* @bug 4503092 8024883
|
||||
* @summary Tests that Windows Selector can use more than 63 channels
|
||||
* @run main/timeout=300 LotsOfChannels
|
||||
* @run main LotsOfChannels
|
||||
* @run main/othervm -Dsun.nio.ch.maxUpdateArraySize=64 LotsOfChannels
|
||||
* @author kladko
|
||||
*/
|
||||
|
||||
|
||||
@ -22,12 +22,13 @@
|
||||
*/
|
||||
|
||||
/* @test
|
||||
* @bug 4777504
|
||||
* @bug 4777504 8024883
|
||||
* @summary Ensure that a Selector can return at least 100 selected keys
|
||||
* @author Mark Reinhold
|
||||
* @library ..
|
||||
* @build SelectorLimit
|
||||
* @run main/othervm SelectorLimit
|
||||
* @run main/othervm -Dsun.nio.ch.maxUpdateArraySize=128 SelectorLimit
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user