Mercurial Hosting > luan
changeset 961:790c01734386
make SelectChannelEndPoint._key final
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 13 Oct 2016 22:03:24 -0600 |
parents | 3cd4c706a61f |
children | 94498d6daf5b |
files | src/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java |
diffstat | 1 files changed, 12 insertions(+), 60 deletions(-) [+] |
line wrap: on
line diff
diff -r 3cd4c706a61f -r 790c01734386 src/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java --- a/src/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java Thu Oct 13 21:29:19 2016 -0600 +++ b/src/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java Thu Oct 13 22:03:24 2016 -0600 @@ -47,7 +47,7 @@ private final SelectorManager.SelectSet _selectSet; private final SelectorManager _manager; - private SelectionKey _key; + private final SelectionKey _key; private final Runnable _handler = new Runnable() { public void run() { handle(); } @@ -110,7 +110,7 @@ public synchronized void schedule() { // If there is no key, then do nothing - if (_key == null || !_key.isValid()) + if (!_key.isValid()) { _readBlocked = false; _writeBlocked = false; @@ -341,11 +341,11 @@ | ((!_socket.isOutputShutdown()&& write_interest) ? SelectionKey.OP_WRITE : 0); try { - current_ops = ((_key!=null && _key.isValid())?_key.interestOps():-1); + current_ops = ((_key.isValid())?_key.interestOps():-1); } catch(Exception e) { - _key = null; + _key.cancel(); LOG.trace("",e); } } @@ -368,52 +368,11 @@ { if (getChannel().isOpen()) { - if (_interestOps>0) - { - if (_key==null || !_key.isValid()) - { - SelectableChannel sc = (SelectableChannel)getChannel(); - if (sc.isRegistered()) - { - updateKey(); - } - else - { - try - { - _key = _selectSet.getSelector().register(sc,_interestOps,this); - } - catch (Exception e) - { - LOG.trace("",e); - if (_key!=null && _key.isValid()) - { - _key.cancel(); - } - - _key = null; - } - } - } - else - { - _key.interestOps(_interestOps); - } - } - else - { - if (_key!=null && _key.isValid()) - _key.interestOps(0); - else - _key = null; - } + _key.interestOps(_interestOps); } else { - if (_key!=null && _key.isValid()) - _key.cancel(); - - _key = null; + _key.cancel(); } } @@ -508,23 +467,16 @@ // We do a best effort to print the right toString() and that's it. SelectionKey key = _key; String keyString = ""; - if (key != null) + if (key.isValid()) { - if (key.isValid()) - { - if (key.isReadable()) - keyString += "r"; - if (key.isWritable()) - keyString += "w"; - } - else - { - keyString += "!"; - } + if (key.isReadable()) + keyString += "r"; + if (key.isWritable()) + keyString += "w"; } else { - keyString += "-"; + keyString += "!"; } return String.format("SCEP@%x{l(%s)<->r(%s),s=%d,open=%b,ishut=%b,oshut=%b,rb=%b,wb=%b,w=%b,i=%d%s}-{%s}", hashCode(),