comparison src/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java @ 915:65e0fba5861a

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 09 Oct 2016 01:52:29 -0600
parents 54308d65265a
children b77d631b9e28
comparison
equal deleted inserted replaced
914:54308d65265a 915:65e0fba5861a
43 */ 43 */
44 public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPoint, ConnectedEndPoint 44 public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPoint, ConnectedEndPoint
45 { 45 {
46 public static final Logger LOG=LoggerFactory.getLogger("org.eclipse.jetty.io.nio"); 46 public static final Logger LOG=LoggerFactory.getLogger("org.eclipse.jetty.io.nio");
47 47
48 private final boolean WORK_AROUND_JVM_BUG_6346658 = System.getProperty("os.name").toLowerCase(Locale.ENGLISH).contains("win");
49 private final SelectorManager.SelectSet _selectSet; 48 private final SelectorManager.SelectSet _selectSet;
50 private final SelectorManager _manager; 49 private final SelectorManager _manager;
51 private SelectionKey _key; 50 private SelectionKey _key;
52 private final Runnable _handler = new Runnable() 51 private final Runnable _handler = new Runnable()
53 { 52 {
762 * @see org.eclipse.io.nio.ChannelEndPoint#close() 761 * @see org.eclipse.io.nio.ChannelEndPoint#close()
763 */ 762 */
764 @Override 763 @Override
765 public void close() throws IOException 764 public void close() throws IOException
766 { 765 {
767 // On unix systems there is a JVM issue that if you cancel before closing, it can
768 // cause the selector to block waiting for a channel to close and that channel can
769 // block waiting for the remote end. But on windows, if you don't cancel before a
770 // close, then the selector can block anyway!
771 // https://bugs.eclipse.org/bugs/show_bug.cgi?id=357318
772 if (WORK_AROUND_JVM_BUG_6346658)
773 {
774 try
775 {
776 SelectionKey key = _key;
777 if (key!=null)
778 key.cancel();
779 }
780 catch (Throwable e)
781 {
782 LOG.trace("",e);
783 }
784 }
785
786 try 766 try
787 { 767 {
788 super.close(); 768 super.close();
789 } 769 }
790 catch (IOException e) 770 catch (IOException e)