jdk/src/share/classes/sun/nio/ch/SocketChannelImpl.java
changeset 22607 ba232b417248
parent 22339 e91bfaf4360d
parent 22604 9b394795e216
child 23010 6dadb192ad81
equal deleted inserted replaced
22585:cb36782f6044 22607:ba232b417248
   886                                      SelectionKeyImpl sk) {
   886                                      SelectionKeyImpl sk) {
   887         int intOps = sk.nioInterestOps(); // Do this just once, it synchronizes
   887         int intOps = sk.nioInterestOps(); // Do this just once, it synchronizes
   888         int oldOps = sk.nioReadyOps();
   888         int oldOps = sk.nioReadyOps();
   889         int newOps = initialOps;
   889         int newOps = initialOps;
   890 
   890 
   891         if ((ops & PollArrayWrapper.POLLNVAL) != 0) {
   891         if ((ops & Net.POLLNVAL) != 0) {
   892             // This should only happen if this channel is pre-closed while a
   892             // This should only happen if this channel is pre-closed while a
   893             // selection operation is in progress
   893             // selection operation is in progress
   894             // ## Throw an error if this channel has not been pre-closed
   894             // ## Throw an error if this channel has not been pre-closed
   895             return false;
   895             return false;
   896         }
   896         }
   897 
   897 
   898         if ((ops & (PollArrayWrapper.POLLERR
   898         if ((ops & (Net.POLLERR | Net.POLLHUP)) != 0) {
   899                     | PollArrayWrapper.POLLHUP)) != 0) {
       
   900             newOps = intOps;
   899             newOps = intOps;
   901             sk.nioReadyOps(newOps);
   900             sk.nioReadyOps(newOps);
   902             // No need to poll again in checkConnect,
   901             // No need to poll again in checkConnect,
   903             // the error will be detected there
   902             // the error will be detected there
   904             readyToConnect = true;
   903             readyToConnect = true;
   905             return (newOps & ~oldOps) != 0;
   904             return (newOps & ~oldOps) != 0;
   906         }
   905         }
   907 
   906 
   908         if (((ops & PollArrayWrapper.POLLIN) != 0) &&
   907         if (((ops & Net.POLLIN) != 0) &&
   909             ((intOps & SelectionKey.OP_READ) != 0) &&
   908             ((intOps & SelectionKey.OP_READ) != 0) &&
   910             (state == ST_CONNECTED))
   909             (state == ST_CONNECTED))
   911             newOps |= SelectionKey.OP_READ;
   910             newOps |= SelectionKey.OP_READ;
   912 
   911 
   913         if (((ops & PollArrayWrapper.POLLCONN) != 0) &&
   912         if (((ops & Net.POLLCONN) != 0) &&
   914             ((intOps & SelectionKey.OP_CONNECT) != 0) &&
   913             ((intOps & SelectionKey.OP_CONNECT) != 0) &&
   915             ((state == ST_UNCONNECTED) || (state == ST_PENDING))) {
   914             ((state == ST_UNCONNECTED) || (state == ST_PENDING))) {
   916             newOps |= SelectionKey.OP_CONNECT;
   915             newOps |= SelectionKey.OP_CONNECT;
   917             readyToConnect = true;
   916             readyToConnect = true;
   918         }
   917         }
   919 
   918 
   920         if (((ops & PollArrayWrapper.POLLOUT) != 0) &&
   919         if (((ops & Net.POLLOUT) != 0) &&
   921             ((intOps & SelectionKey.OP_WRITE) != 0) &&
   920             ((intOps & SelectionKey.OP_WRITE) != 0) &&
   922             (state == ST_CONNECTED))
   921             (state == ST_CONNECTED))
   923             newOps |= SelectionKey.OP_WRITE;
   922             newOps |= SelectionKey.OP_WRITE;
   924 
   923 
   925         sk.nioReadyOps(newOps);
   924         sk.nioReadyOps(newOps);
   960      * Translates an interest operation set into a native poll event set
   959      * Translates an interest operation set into a native poll event set
   961      */
   960      */
   962     public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) {
   961     public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) {
   963         int newOps = 0;
   962         int newOps = 0;
   964         if ((ops & SelectionKey.OP_READ) != 0)
   963         if ((ops & SelectionKey.OP_READ) != 0)
   965             newOps |= PollArrayWrapper.POLLIN;
   964             newOps |= Net.POLLIN;
   966         if ((ops & SelectionKey.OP_WRITE) != 0)
   965         if ((ops & SelectionKey.OP_WRITE) != 0)
   967             newOps |= PollArrayWrapper.POLLOUT;
   966             newOps |= Net.POLLOUT;
   968         if ((ops & SelectionKey.OP_CONNECT) != 0)
   967         if ((ops & SelectionKey.OP_CONNECT) != 0)
   969             newOps |= PollArrayWrapper.POLLCONN;
   968             newOps |= Net.POLLCONN;
   970         sk.selector.putEventOps(sk, newOps);
   969         sk.selector.putEventOps(sk, newOps);
   971     }
   970     }
   972 
   971 
   973     public FileDescriptor getFD() {
   972     public FileDescriptor getFD() {
   974         return fd;
   973         return fd;