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

8031997: PPC64: Make the various POLL constants system dependant

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