提交 3d7a9092 编写于 作者: S simonis

8031997: PPC64: Make the various POLL constants system dependant

Reviewed-by: alanb
上级 dec1dfd1
......@@ -117,6 +117,12 @@ SUNWprivate_1.1 {
Java_sun_nio_ch_Net_getInterface6;
Java_sun_nio_ch_Net_shutdown;
Java_sun_nio_ch_Net_poll;
Java_sun_nio_ch_Net_pollinValue;
Java_sun_nio_ch_Net_polloutValue;
Java_sun_nio_ch_Net_pollerrValue;
Java_sun_nio_ch_Net_pollhupValue;
Java_sun_nio_ch_Net_pollnvalValue;
Java_sun_nio_ch_Net_pollconnValue;
Java_sun_nio_ch_Net_isExclusiveBindAvailable;
Java_sun_nio_ch_PollArrayWrapper_interrupt;
Java_sun_nio_ch_PollArrayWrapper_poll0;
......
......@@ -109,6 +109,12 @@ SUNWprivate_1.1 {
Java_sun_nio_ch_Net_getInterface6;
Java_sun_nio_ch_Net_shutdown;
Java_sun_nio_ch_Net_poll;
Java_sun_nio_ch_Net_pollinValue;
Java_sun_nio_ch_Net_polloutValue;
Java_sun_nio_ch_Net_pollerrValue;
Java_sun_nio_ch_Net_pollhupValue;
Java_sun_nio_ch_Net_pollnvalValue;
Java_sun_nio_ch_Net_pollconnValue;
Java_sun_nio_ch_Net_isExclusiveBindAvailable;
Java_sun_nio_ch_PollArrayWrapper_interrupt;
Java_sun_nio_ch_PollArrayWrapper_poll0;
......
......@@ -105,6 +105,12 @@ SUNWprivate_1.1 {
Java_sun_nio_ch_Net_getInterface6;
Java_sun_nio_ch_Net_shutdown;
Java_sun_nio_ch_Net_poll;
Java_sun_nio_ch_Net_pollinValue;
Java_sun_nio_ch_Net_polloutValue;
Java_sun_nio_ch_Net_pollerrValue;
Java_sun_nio_ch_Net_pollhupValue;
Java_sun_nio_ch_Net_pollnvalValue;
Java_sun_nio_ch_Net_pollconnValue;
Java_sun_nio_ch_Net_isExclusiveBindAvailable;
Java_sun_nio_ch_PollArrayWrapper_interrupt;
Java_sun_nio_ch_PollArrayWrapper_poll0;
......
......@@ -148,7 +148,7 @@ final class AixPollPort
try {
socketpair(sv);
// register one end with pollset
pollsetCtl(pollset, PS_ADD, sv[0], POLLIN);
pollsetCtl(pollset, PS_ADD, sv[0], Net.POLLIN);
} catch (IOException x) {
pollsetDestroy(pollset);
throw x;
......@@ -160,7 +160,7 @@ final class AixPollPort
try {
socketpair(sv);
// register one end with pollset
pollsetCtl(pollset, PS_ADD, sv[0], POLLIN);
pollsetCtl(pollset, PS_ADD, sv[0], Net.POLLIN);
} catch (IOException x) {
pollsetDestroy(pollset);
throw x;
......@@ -353,7 +353,7 @@ final class AixPollPort
// This is the only file descriptor without
// one shot semantic => register it again.
pollsetCtl(pollset, PS_ADD, sp[0], POLLIN);
pollsetCtl(pollset, PS_ADD, sp[0], Net.POLLIN);
// queue special event if there are more events
// to handle.
......@@ -370,7 +370,7 @@ final class AixPollPort
drain1(ctlSp[0]);
// This file descriptor does not have
// one shot semantic => register it again.
pollsetCtl(pollset, PS_ADD, ctlSp[0], POLLIN);
pollsetCtl(pollset, PS_ADD, ctlSp[0], Net.POLLIN);
processControlQueue();
}
continue;
......
......@@ -53,10 +53,6 @@ import java.util.LinkedList;
*/
class KQueueArrayWrapper {
// Event masks
static final short POLLIN = AbstractPollArrayWrapper.POLLIN;
static final short POLLOUT = AbstractPollArrayWrapper.POLLOUT;
// kevent filters
static short EVFILT_READ;
static short EVFILT_WRITE;
......@@ -129,9 +125,9 @@ class KQueueArrayWrapper {
// SinkChannelImpl, SourceChannelImpl, DatagramChannelImpl,
// ServerSocketChannelImpl, SocketChannelImpl
if (filter == EVFILT_READ) {
result |= POLLIN;
result |= Net.POLLIN;
} else if (filter == EVFILT_WRITE) {
result |= POLLOUT;
result |= Net.POLLOUT;
}
return result;
......@@ -180,7 +176,7 @@ class KQueueArrayWrapper {
if (!ch.isOpen())
continue;
register0(kq, ch.getFDVal(), u.events & POLLIN, u.events & POLLOUT);
register0(kq, ch.getFDVal(), u.events & Net.POLLIN, u.events & Net.POLLOUT);
}
}
}
......
......@@ -37,14 +37,6 @@ import sun.misc.*;
public abstract class AbstractPollArrayWrapper {
// Event masks
public static final short POLLIN = 0x0001;
public static final short POLLOUT = 0x0004;
public static final short POLLERR = 0x0008;
public static final short POLLHUP = 0x0010;
public static final short POLLNVAL = 0x0020;
public static final short POLLREMOVE = 0x0800;
// Miscellaneous constants
static final short SIZE_POLLFD = 8;
static final short FD_OFFSET = 0;
......
......@@ -1042,25 +1042,24 @@ class DatagramChannelImpl
int oldOps = sk.nioReadyOps();
int newOps = initialOps;
if ((ops & PollArrayWrapper.POLLNVAL) != 0) {
if ((ops & Net.POLLNVAL) != 0) {
// This should only happen if this channel is pre-closed while a
// selection operation is in progress
// ## Throw an error if this channel has not been pre-closed
return false;
}
if ((ops & (PollArrayWrapper.POLLERR
| PollArrayWrapper.POLLHUP)) != 0) {
if ((ops & (Net.POLLERR | Net.POLLHUP)) != 0) {
newOps = intOps;
sk.nioReadyOps(newOps);
return (newOps & ~oldOps) != 0;
}
if (((ops & PollArrayWrapper.POLLIN) != 0) &&
if (((ops & Net.POLLIN) != 0) &&
((intOps & SelectionKey.OP_READ) != 0))
newOps |= SelectionKey.OP_READ;
if (((ops & PollArrayWrapper.POLLOUT) != 0) &&
if (((ops & Net.POLLOUT) != 0) &&
((intOps & SelectionKey.OP_WRITE) != 0))
newOps |= SelectionKey.OP_WRITE;
......@@ -1105,11 +1104,11 @@ class DatagramChannelImpl
int newOps = 0;
if ((ops & SelectionKey.OP_READ) != 0)
newOps |= PollArrayWrapper.POLLIN;
newOps |= Net.POLLIN;
if ((ops & SelectionKey.OP_WRITE) != 0)
newOps |= PollArrayWrapper.POLLOUT;
newOps |= Net.POLLOUT;
if ((ops & SelectionKey.OP_CONNECT) != 0)
newOps |= PollArrayWrapper.POLLIN;
newOps |= Net.POLLIN;
sk.selector.putEventOps(sk, newOps);
}
......
......@@ -187,9 +187,9 @@ public class DatagramSocketAdaptor
if (!dc.isOpen())
throw new ClosedChannelException();
long st = System.currentTimeMillis();
int result = dc.poll(PollArrayWrapper.POLLIN, to);
int result = dc.poll(Net.POLLIN, to);
if (result > 0 &&
((result & PollArrayWrapper.POLLIN) != 0)) {
((result & Net.POLLIN) != 0)) {
if ((sender = dc.receive(bb)) != null)
return sender;
}
......
......@@ -581,9 +581,34 @@ public class Net {
private static native void initIDs();
/**
* Event masks for the various poll system calls.
* They will be set platform dependant in the static initializer below.
*/
public static final short POLLIN;
public static final short POLLOUT;
public static final short POLLERR;
public static final short POLLHUP;
public static final short POLLNVAL;
public static final short POLLCONN;
static native short pollinValue();
static native short polloutValue();
static native short pollerrValue();
static native short pollhupValue();
static native short pollnvalValue();
static native short pollconnValue();
static {
IOUtil.load();
initIDs();
POLLIN = pollinValue();
POLLOUT = polloutValue();
POLLERR = pollerrValue();
POLLHUP = pollhupValue();
POLLNVAL = pollnvalValue();
POLLCONN = pollconnValue();
}
}
......@@ -113,7 +113,7 @@ public class ServerSocketAdaptor // package-private
if (!ssc.isOpen())
throw new ClosedChannelException();
long st = System.currentTimeMillis();
int result = ssc.poll(PollArrayWrapper.POLLIN, to);
int result = ssc.poll(Net.POLLIN, to);
if (result > 0 && ((sc = ssc.accept()) != null))
return sc.socket();
to -= System.currentTimeMillis() - st;
......
......@@ -309,21 +309,20 @@ class ServerSocketChannelImpl
int oldOps = sk.nioReadyOps();
int newOps = initialOps;
if ((ops & PollArrayWrapper.POLLNVAL) != 0) {
if ((ops & Net.POLLNVAL) != 0) {
// This should only happen if this channel is pre-closed while a
// selection operation is in progress
// ## Throw an error if this channel has not been pre-closed
return false;
}
if ((ops & (PollArrayWrapper.POLLERR
| PollArrayWrapper.POLLHUP)) != 0) {
if ((ops & (Net.POLLERR | Net.POLLHUP)) != 0) {
newOps = intOps;
sk.nioReadyOps(newOps);
return (newOps & ~oldOps) != 0;
}
if (((ops & PollArrayWrapper.POLLIN) != 0) &&
if (((ops & Net.POLLIN) != 0) &&
((intOps & SelectionKey.OP_ACCEPT) != 0))
newOps |= SelectionKey.OP_ACCEPT;
......@@ -369,7 +368,7 @@ class ServerSocketChannelImpl
// Translate ops
if ((ops & SelectionKey.OP_ACCEPT) != 0)
newOps |= PollArrayWrapper.POLLIN;
newOps |= Net.POLLIN;
// Place ops into pollfd array
sk.selector.putEventOps(sk, newOps);
}
......
......@@ -107,7 +107,7 @@ public class SocketAdaptor
throw new ClosedChannelException();
long st = System.currentTimeMillis();
int result = sc.poll(PollArrayWrapper.POLLCONN, to);
int result = sc.poll(Net.POLLCONN, to);
if (result > 0 && sc.finishConnect())
break;
to -= System.currentTimeMillis() - st;
......@@ -201,7 +201,7 @@ public class SocketAdaptor
if (!sc.isOpen())
throw new ClosedChannelException();
long st = System.currentTimeMillis();
int result = sc.poll(PollArrayWrapper.POLLIN, to);
int result = sc.poll(Net.POLLIN, to);
if (result > 0) {
if ((n = sc.read(bb)) != 0)
return n;
......
......@@ -884,15 +884,14 @@ class SocketChannelImpl
int oldOps = sk.nioReadyOps();
int newOps = initialOps;
if ((ops & PollArrayWrapper.POLLNVAL) != 0) {
if ((ops & Net.POLLNVAL) != 0) {
// This should only happen if this channel is pre-closed while a
// selection operation is in progress
// ## Throw an error if this channel has not been pre-closed
return false;
}
if ((ops & (PollArrayWrapper.POLLERR
| PollArrayWrapper.POLLHUP)) != 0) {
if ((ops & (Net.POLLERR | Net.POLLHUP)) != 0) {
newOps = intOps;
sk.nioReadyOps(newOps);
// No need to poll again in checkConnect,
......@@ -901,19 +900,19 @@ class SocketChannelImpl
return (newOps & ~oldOps) != 0;
}
if (((ops & PollArrayWrapper.POLLIN) != 0) &&
if (((ops & Net.POLLIN) != 0) &&
((intOps & SelectionKey.OP_READ) != 0) &&
(state == ST_CONNECTED))
newOps |= SelectionKey.OP_READ;
if (((ops & PollArrayWrapper.POLLCONN) != 0) &&
if (((ops & Net.POLLCONN) != 0) &&
((intOps & SelectionKey.OP_CONNECT) != 0) &&
((state == ST_UNCONNECTED) || (state == ST_PENDING))) {
newOps |= SelectionKey.OP_CONNECT;
readyToConnect = true;
}
if (((ops & PollArrayWrapper.POLLOUT) != 0) &&
if (((ops & Net.POLLOUT) != 0) &&
((intOps & SelectionKey.OP_WRITE) != 0) &&
(state == ST_CONNECTED))
newOps |= SelectionKey.OP_WRITE;
......@@ -958,11 +957,11 @@ class SocketChannelImpl
public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) {
int newOps = 0;
if ((ops & SelectionKey.OP_READ) != 0)
newOps |= PollArrayWrapper.POLLIN;
newOps |= Net.POLLIN;
if ((ops & SelectionKey.OP_WRITE) != 0)
newOps |= PollArrayWrapper.POLLOUT;
newOps |= Net.POLLOUT;
if ((ops & SelectionKey.OP_CONNECT) != 0)
newOps |= PollArrayWrapper.POLLCONN;
newOps |= Net.POLLCONN;
sk.selector.putEventOps(sk, newOps);
}
......
......@@ -93,7 +93,7 @@ final class EPollPort
try {
socketpair(sv);
// register one end with epoll
epollCtl(epfd, EPOLL_CTL_ADD, sv[0], POLLIN);
epollCtl(epfd, EPOLL_CTL_ADD, sv[0], Net.POLLIN);
} catch (IOException x) {
close0(epfd);
throw x;
......
......@@ -172,9 +172,9 @@ final class KQueuePort
// TBD: Measure cost of EV_ONESHOT vs. EV_CLEAR, either will do here.
int err = 0;
int flags = (EV_ADD|EV_ONESHOT);
if ((events & Port.POLLIN) > 0)
if ((events & Net.POLLIN) > 0)
err = keventRegister(kqfd, fd, EVFILT_READ, flags);
if (err == 0 && (events & Port.POLLOUT) > 0)
if (err == 0 && (events & Net.POLLOUT) > 0)
err = keventRegister(kqfd, fd, EVFILT_WRITE, flags);
if (err != 0)
throw new InternalError("kevent failed: " + err); // should not happen
......@@ -227,9 +227,9 @@ final class KQueuePort
int filter = getFilter(keventAddress);
int events = 0;
if (filter == EVFILT_READ)
events = Port.POLLIN;
events = Net.POLLIN;
else if (filter == EVFILT_WRITE)
events = Port.POLLOUT;
events = Net.POLLOUT;
Event ev = new Event(channel, events);
......
......@@ -43,8 +43,6 @@ import sun.misc.*;
public class PollArrayWrapper extends AbstractPollArrayWrapper {
public static final short POLLCONN = POLLOUT;
// File descriptor to write for interrupt
int interruptFD;
......@@ -58,7 +56,7 @@ public class PollArrayWrapper extends AbstractPollArrayWrapper {
void initInterrupt(int fd0, int fd1) {
interruptFD = fd1;
putDescriptor(0, fd0);
putEventOps(0, POLLIN);
putEventOps(0, Net.POLLIN);
putReventOps(0, 0);
}
......
......@@ -40,10 +40,6 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
*/
abstract class Port extends AsynchronousChannelGroupImpl {
static final short POLLIN = 0x0001;
static final short POLLOUT = 0x0004;
static final short POLLERR = 0x0008;
static final short POLLHUP = 0x0010;
/**
* Implemented by clients registered with this port.
......
......@@ -118,17 +118,16 @@ class SinkChannelImpl
int oldOps = sk.nioReadyOps();
int newOps = initialOps;
if ((ops & PollArrayWrapper.POLLNVAL) != 0)
if ((ops & Net.POLLNVAL) != 0)
throw new Error("POLLNVAL detected");
if ((ops & (PollArrayWrapper.POLLERR
| PollArrayWrapper.POLLHUP)) != 0) {
if ((ops & (Net.POLLERR | Net.POLLHUP)) != 0) {
newOps = intOps;
sk.nioReadyOps(newOps);
return (newOps & ~oldOps) != 0;
}
if (((ops & PollArrayWrapper.POLLOUT) != 0) &&
if (((ops & Net.POLLOUT) != 0) &&
((intOps & SelectionKey.OP_WRITE) != 0))
newOps |= SelectionKey.OP_WRITE;
......@@ -146,7 +145,7 @@ class SinkChannelImpl
public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) {
if (ops == SelectionKey.OP_WRITE)
ops = PollArrayWrapper.POLLOUT;
ops = Net.POLLOUT;
sk.selector.putEventOps(sk, ops);
}
......
......@@ -118,17 +118,16 @@ class SourceChannelImpl
int oldOps = sk.nioReadyOps();
int newOps = initialOps;
if ((ops & PollArrayWrapper.POLLNVAL) != 0)
if ((ops & Net.POLLNVAL) != 0)
throw new Error("POLLNVAL detected");
if ((ops & (PollArrayWrapper.POLLERR
| PollArrayWrapper.POLLHUP)) != 0) {
if ((ops & (Net.POLLERR | Net.POLLHUP)) != 0) {
newOps = intOps;
sk.nioReadyOps(newOps);
return (newOps & ~oldOps) != 0;
}
if (((ops & PollArrayWrapper.POLLIN) != 0) &&
if (((ops & Net.POLLIN) != 0) &&
((intOps & SelectionKey.OP_READ) != 0))
newOps |= SelectionKey.OP_READ;
......@@ -146,7 +145,7 @@ class SourceChannelImpl
public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) {
if (ops == SelectionKey.OP_READ)
ops = PollArrayWrapper.POLLIN;
ops = Net.POLLIN;
sk.selector.putEventOps(sk, ops);
}
......
......@@ -148,7 +148,7 @@ class UnixAsynchronousServerSocketChannelImpl
synchronized (updateLock) {
acceptPending = true;
}
port.startPoll(fdVal, Port.POLLIN);
port.startPoll(fdVal, Net.POLLIN);
return;
}
......@@ -299,7 +299,7 @@ class UnixAsynchronousServerSocketChannelImpl
}
// register for connections
port.startPoll(fdVal, Port.POLLIN);
port.startPoll(fdVal, Net.POLLIN);
return result;
}
} catch (Throwable x) {
......
......@@ -142,9 +142,9 @@ class UnixAsynchronousSocketChannelImpl
assert Thread.holdsLock(updateLock);
int events = 0;
if (readPending)
events |= Port.POLLIN;
events |= Net.POLLIN;
if (connectPending || writePending)
events |= Port.POLLOUT;
events |= Net.POLLOUT;
if (events != 0)
port.startPoll(fdVal, events);
}
......@@ -204,9 +204,9 @@ class UnixAsynchronousSocketChannelImpl
*/
@Override
public void onEvent(int events, boolean mayInvokeDirect) {
boolean readable = (events & Port.POLLIN) > 0;
boolean writable = (events & Port.POLLOUT) > 0;
if ((events & (Port.POLLERR | Port.POLLHUP)) > 0) {
boolean readable = (events & Net.POLLIN) > 0;
boolean writable = (events & Net.POLLOUT) > 0;
if ((events & (Net.POLLERR | Net.POLLHUP)) > 0) {
readable = true;
writable = true;
}
......
......@@ -589,15 +589,14 @@ public class SctpChannelImpl extends SctpChannel
int oldOps = sk.nioReadyOps();
int newOps = initialOps;
if ((ops & PollArrayWrapper.POLLNVAL) != 0) {
if ((ops & Net.POLLNVAL) != 0) {
/* This should only happen if this channel is pre-closed while a
* selection operation is in progress
* ## Throw an error if this channel has not been pre-closed */
return false;
}
if ((ops & (PollArrayWrapper.POLLERR
| PollArrayWrapper.POLLHUP)) != 0) {
if ((ops & (Net.POLLERR | Net.POLLHUP)) != 0) {
newOps = intOps;
sk.nioReadyOps(newOps);
/* No need to poll again in checkConnect,
......@@ -606,19 +605,19 @@ public class SctpChannelImpl extends SctpChannel
return (newOps & ~oldOps) != 0;
}
if (((ops & PollArrayWrapper.POLLIN) != 0) &&
if (((ops & Net.POLLIN) != 0) &&
((intOps & SelectionKey.OP_READ) != 0) &&
isConnected())
newOps |= SelectionKey.OP_READ;
if (((ops & PollArrayWrapper.POLLCONN) != 0) &&
if (((ops & Net.POLLCONN) != 0) &&
((intOps & SelectionKey.OP_CONNECT) != 0) &&
((state == ChannelState.UNCONNECTED) || (state == ChannelState.PENDING))) {
newOps |= SelectionKey.OP_CONNECT;
readyToConnect = true;
}
if (((ops & PollArrayWrapper.POLLOUT) != 0) &&
if (((ops & Net.POLLOUT) != 0) &&
((intOps & SelectionKey.OP_WRITE) != 0) &&
isConnected())
newOps |= SelectionKey.OP_WRITE;
......@@ -642,11 +641,11 @@ public class SctpChannelImpl extends SctpChannel
public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) {
int newOps = 0;
if ((ops & SelectionKey.OP_READ) != 0)
newOps |= PollArrayWrapper.POLLIN;
newOps |= Net.POLLIN;
if ((ops & SelectionKey.OP_WRITE) != 0)
newOps |= PollArrayWrapper.POLLOUT;
newOps |= Net.POLLOUT;
if ((ops & SelectionKey.OP_CONNECT) != 0)
newOps |= PollArrayWrapper.POLLCONN;
newOps |= Net.POLLCONN;
sk.selector.putEventOps(sk, newOps);
}
......
......@@ -321,25 +321,24 @@ public class SctpMultiChannelImpl extends SctpMultiChannel
int oldOps = sk.nioReadyOps();
int newOps = initialOps;
if ((ops & PollArrayWrapper.POLLNVAL) != 0) {
if ((ops & Net.POLLNVAL) != 0) {
/* This should only happen if this channel is pre-closed while a
* selection operation is in progress
* ## Throw an error if this channel has not been pre-closed */
return false;
}
if ((ops & (PollArrayWrapper.POLLERR
| PollArrayWrapper.POLLHUP)) != 0) {
if ((ops & (Net.POLLERR | Net.POLLHUP)) != 0) {
newOps = intOps;
sk.nioReadyOps(newOps);
return (newOps & ~oldOps) != 0;
}
if (((ops & PollArrayWrapper.POLLIN) != 0) &&
if (((ops & Net.POLLIN) != 0) &&
((intOps & SelectionKey.OP_READ) != 0))
newOps |= SelectionKey.OP_READ;
if (((ops & PollArrayWrapper.POLLOUT) != 0) &&
if (((ops & Net.POLLOUT) != 0) &&
((intOps & SelectionKey.OP_WRITE) != 0))
newOps |= SelectionKey.OP_WRITE;
......@@ -361,9 +360,9 @@ public class SctpMultiChannelImpl extends SctpMultiChannel
public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) {
int newOps = 0;
if ((ops & SelectionKey.OP_READ) != 0)
newOps |= PollArrayWrapper.POLLIN;
newOps |= Net.POLLIN;
if ((ops & SelectionKey.OP_WRITE) != 0)
newOps |= PollArrayWrapper.POLLOUT;
newOps |= Net.POLLOUT;
sk.selector.putEventOps(sk, newOps);
}
......
......@@ -314,21 +314,20 @@ public class SctpServerChannelImpl extends SctpServerChannel
int oldOps = sk.nioReadyOps();
int newOps = initialOps;
if ((ops & PollArrayWrapper.POLLNVAL) != 0) {
if ((ops & Net.POLLNVAL) != 0) {
/* This should only happen if this channel is pre-closed while a
* selection operation is in progress
* ## Throw an error if this channel has not been pre-closed */
return false;
}
if ((ops & (PollArrayWrapper.POLLERR
| PollArrayWrapper.POLLHUP)) != 0) {
if ((ops & (Net.POLLERR | Net.POLLHUP)) != 0) {
newOps = intOps;
sk.nioReadyOps(newOps);
return (newOps & ~oldOps) != 0;
}
if (((ops & PollArrayWrapper.POLLIN) != 0) &&
if (((ops & Net.POLLIN) != 0) &&
((intOps & SelectionKey.OP_ACCEPT) != 0))
newOps |= SelectionKey.OP_ACCEPT;
......@@ -352,7 +351,7 @@ public class SctpServerChannelImpl extends SctpServerChannel
/* Translate ops */
if ((ops & SelectionKey.OP_ACCEPT) != 0)
newOps |= PollArrayWrapper.POLLIN;
newOps |= Net.POLLIN;
/* Place ops into pollfd array */
sk.selector.putEventOps(sk, newOps);
......
......@@ -145,7 +145,6 @@ Java_sun_nio_ch_IOUtil_iovMax(JNIEnv *env, jclass this)
return (jint)iov_max;
}
/* Declared in nio_util.h for use elsewhere in NIO */
jint
......
......@@ -23,6 +23,7 @@
* questions.
*/
#include <sys/poll.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <string.h>
......@@ -749,6 +750,42 @@ Java_sun_nio_ch_Net_poll(JNIEnv* env, jclass this, jobject fdo, jint events, jlo
}
}
JNIEXPORT jshort JNICALL
Java_sun_nio_ch_Net_pollinValue(JNIEnv *env, jclass this)
{
return (jshort)POLLIN;
}
JNIEXPORT jshort JNICALL
Java_sun_nio_ch_Net_polloutValue(JNIEnv *env, jclass this)
{
return (jshort)POLLOUT;
}
JNIEXPORT jshort JNICALL
Java_sun_nio_ch_Net_pollerrValue(JNIEnv *env, jclass this)
{
return (jshort)POLLERR;
}
JNIEXPORT jshort JNICALL
Java_sun_nio_ch_Net_pollhupValue(JNIEnv *env, jclass this)
{
return (jshort)POLLHUP;
}
JNIEXPORT jshort JNICALL
Java_sun_nio_ch_Net_pollnvalValue(JNIEnv *env, jclass this)
{
return (jshort)POLLNVAL;
}
JNIEXPORT jshort JNICALL
Java_sun_nio_ch_Net_pollconnValue(JNIEnv *env, jclass this)
{
return (jshort)POLLOUT;
}
/* Declared in nio_util.h */
......
......@@ -53,15 +53,6 @@ class PollArrayWrapper {
static short SIZE_POLLFD = 8; // sizeof pollfd struct
// events masks
@Native static final short POLLIN = AbstractPollArrayWrapper.POLLIN;
@Native static final short POLLOUT = AbstractPollArrayWrapper.POLLOUT;
@Native static final short POLLERR = AbstractPollArrayWrapper.POLLERR;
@Native static final short POLLHUP = AbstractPollArrayWrapper.POLLHUP;
@Native static final short POLLNVAL = AbstractPollArrayWrapper.POLLNVAL;
@Native static final short POLLREMOVE = AbstractPollArrayWrapper.POLLREMOVE;
@Native static final short POLLCONN = 0x0002;
private int size; // Size of the pollArray
PollArrayWrapper(int newSize) {
......@@ -119,6 +110,6 @@ class PollArrayWrapper {
// Adds Windows wakeup socket at a given index.
void addWakeupSocket(int fdVal, int index) {
putDescriptor(index, fdVal);
putEventOps(index, POLLIN);
putEventOps(index, Net.POLLIN);
}
}
......@@ -78,17 +78,16 @@ class SinkChannelImpl
int oldOps = sk.nioReadyOps();
int newOps = initialOps;
if ((ops & PollArrayWrapper.POLLNVAL) != 0)
if ((ops & Net.POLLNVAL) != 0)
throw new Error("POLLNVAL detected");
if ((ops & (PollArrayWrapper.POLLERR
| PollArrayWrapper.POLLHUP)) != 0) {
if ((ops & (Net.POLLERR | Net.POLLHUP)) != 0) {
newOps = intOps;
sk.nioReadyOps(newOps);
return (newOps & ~oldOps) != 0;
}
if (((ops & PollArrayWrapper.POLLOUT) != 0) &&
if (((ops & Net.POLLOUT) != 0) &&
((intOps & SelectionKey.OP_WRITE) != 0))
newOps |= SelectionKey.OP_WRITE;
......@@ -106,7 +105,7 @@ class SinkChannelImpl
public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) {
if ((ops & SelectionKey.OP_WRITE) != 0)
ops = PollArrayWrapper.POLLOUT;
ops = Net.POLLOUT;
sk.selector.putEventOps(sk, ops);
}
......
......@@ -77,17 +77,16 @@ class SourceChannelImpl
int oldOps = sk.nioReadyOps();
int newOps = initialOps;
if ((ops & PollArrayWrapper.POLLNVAL) != 0)
if ((ops & Net.POLLNVAL) != 0)
throw new Error("POLLNVAL detected");
if ((ops & (PollArrayWrapper.POLLERR
| PollArrayWrapper.POLLHUP)) != 0) {
if ((ops & (Net.POLLERR | Net.POLLHUP)) != 0) {
newOps = intOps;
sk.nioReadyOps(newOps);
return (newOps & ~oldOps) != 0;
}
if (((ops & PollArrayWrapper.POLLIN) != 0) &&
if (((ops & Net.POLLIN) != 0) &&
((intOps & SelectionKey.OP_READ) != 0))
newOps |= SelectionKey.OP_READ;
......@@ -105,7 +104,7 @@ class SourceChannelImpl
public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) {
if ((ops & SelectionKey.OP_READ) != 0)
ops = PollArrayWrapper.POLLIN;
ops = Net.POLLIN;
sk.selector.putEventOps(sk, ops);
}
......
......@@ -313,16 +313,16 @@ final class WindowsSelectorImpl extends SelectorImpl {
private int processSelectedKeys(long updateCount) {
int numKeysUpdated = 0;
numKeysUpdated += processFDSet(updateCount, readFds,
PollArrayWrapper.POLLIN,
Net.POLLIN,
false);
numKeysUpdated += processFDSet(updateCount, writeFds,
PollArrayWrapper.POLLCONN |
PollArrayWrapper.POLLOUT,
Net.POLLCONN |
Net.POLLOUT,
false);
numKeysUpdated += processFDSet(updateCount, exceptFds,
PollArrayWrapper.POLLIN |
PollArrayWrapper.POLLCONN |
PollArrayWrapper.POLLOUT,
Net.POLLIN |
Net.POLLCONN |
Net.POLLOUT,
true);
return numKeysUpdated;
}
......
......@@ -554,11 +554,11 @@ Java_sun_nio_ch_Net_poll(JNIEnv* env, jclass this, jobject fdo, jint events, jlo
FD_ZERO(&rd);
FD_ZERO(&wr);
FD_ZERO(&ex);
if (events & sun_nio_ch_PollArrayWrapper_POLLIN) {
if (events & POLLIN) {
FD_SET(fd, &rd);
}
if (events & sun_nio_ch_PollArrayWrapper_POLLOUT ||
events & sun_nio_ch_PollArrayWrapper_POLLCONN) {
if (events & POLLOUT ||
events & POLLCONN) {
FD_SET(fd, &wr);
}
FD_SET(fd, &ex);
......@@ -572,14 +572,50 @@ Java_sun_nio_ch_Net_poll(JNIEnv* env, jclass this, jobject fdo, jint events, jlo
} else if (rv >= 0) {
rv = 0;
if (FD_ISSET(fd, &rd)) {
rv |= sun_nio_ch_PollArrayWrapper_POLLIN;
rv |= POLLIN;
}
if (FD_ISSET(fd, &wr)) {
rv |= sun_nio_ch_PollArrayWrapper_POLLOUT;
rv |= POLLOUT;
}
if (FD_ISSET(fd, &ex)) {
rv |= sun_nio_ch_PollArrayWrapper_POLLERR;
rv |= POLLERR;
}
}
return rv;
}
JNIEXPORT jshort JNICALL
Java_sun_nio_ch_Net_pollinValue(JNIEnv *env, jclass this)
{
return (jshort)POLLIN;
}
JNIEXPORT jshort JNICALL
Java_sun_nio_ch_Net_polloutValue(JNIEnv *env, jclass this)
{
return (jshort)POLLOUT;
}
JNIEXPORT jshort JNICALL
Java_sun_nio_ch_Net_pollerrValue(JNIEnv *env, jclass this)
{
return (jshort)POLLERR;
}
JNIEXPORT jshort JNICALL
Java_sun_nio_ch_Net_pollhupValue(JNIEnv *env, jclass this)
{
return (jshort)POLLHUP;
}
JNIEXPORT jshort JNICALL
Java_sun_nio_ch_Net_pollnvalValue(JNIEnv *env, jclass this)
{
return (jshort)POLLNVAL;
}
JNIEXPORT jshort JNICALL
Java_sun_nio_ch_Net_pollconnValue(JNIEnv *env, jclass this)
{
return (jshort)POLLCONN;
}
......@@ -33,13 +33,15 @@
#define FD_SETSIZE 1024
#include <stdlib.h>
#include <winsock2.h>
#include "jvm.h"
#include "jni.h"
#include "jni_util.h"
#include "sun_nio_ch_WindowsSelectorImpl.h"
#include "sun_nio_ch_PollArrayWrapper.h"
#include "winsock2.h"
#include "nio_util.h" /* Needed for POLL* constants (includes "winsock2.h") */
typedef struct {
jint fd;
......@@ -79,12 +81,11 @@ Java_sun_nio_ch_WindowsSelectorImpl_00024SubSelector_poll0(JNIEnv *env, jobject
/* Set FD_SET structures required for select */
for (i = 0; i < numfds; i++) {
if (fds[i].events & sun_nio_ch_PollArrayWrapper_POLLIN) {
if (fds[i].events & POLLIN) {
readfds.fd_array[read_count] = fds[i].fd;
read_count++;
}
if (fds[i].events & (sun_nio_ch_PollArrayWrapper_POLLOUT |
sun_nio_ch_PollArrayWrapper_POLLCONN))
if (fds[i].events & (POLLOUT | POLLCONN))
{
writefds.fd_array[write_count] = fds[i].fd;
write_count++;
......@@ -110,12 +111,11 @@ Java_sun_nio_ch_WindowsSelectorImpl_00024SubSelector_poll0(JNIEnv *env, jobject
/* prepare select structures for the i-th socket */
errreadfds.fd_count = 0;
errwritefds.fd_count = 0;
if (fds[i].events & sun_nio_ch_PollArrayWrapper_POLLIN) {
if (fds[i].events & POLLIN) {
errreadfds.fd_array[0] = fds[i].fd;
errreadfds.fd_count = 1;
}
if (fds[i].events & (sun_nio_ch_PollArrayWrapper_POLLOUT |
sun_nio_ch_PollArrayWrapper_POLLCONN))
if (fds[i].events & (POLLOUT | POLLCONN))
{
errwritefds.fd_array[0] = fds[i].fd;
errwritefds.fd_count = 1;
......
......@@ -23,6 +23,8 @@
* questions.
*/
#include <winsock2.h>
#include "jni.h"
/**
......@@ -55,3 +57,19 @@ struct iovec {
};
#endif
#ifndef POLLIN
/* WSAPoll()/WSAPOLLFD and the corresponding constants are only defined */
/* in Windows Vista / Windows Server 2008 and later. If we are on an */
/* older release we just use the Solaris constants as this was previously */
/* done in PollArrayWrapper.java. */
#define POLLIN 0x0001
#define POLLOUT 0x0004
#define POLLERR 0x0008
#define POLLHUP 0x0010
#define POLLNVAL 0x0020
#define POLLCONN 0x0002
#else
/* POLLCONN must not equal any of the other constants (see winsock2.h). */
#define POLLCONN 0x2000
#endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册