Author: markt Date: Mon Apr 25 19:03:25 2016 New Revision: 1740876 URL: http://svn.apache.org/viewvc?rev=1740876&view=rev Log: Port fix for multiple socket close warning from trunk
Modified: tomcat/tc8.0.x/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java Modified: tomcat/tc8.0.x/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java URL: http://svn.apache.org/viewvc/tomcat/tc8.0.x/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java?rev=1740876&r1=1740875&r2=1740876&view=diff ============================================================================== --- tomcat/tc8.0.x/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java (original) +++ tomcat/tc8.0.x/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java Mon Apr 25 19:03:25 2016 @@ -633,27 +633,38 @@ public class Nio2Endpoint extends Abstra processSocket0(socket, status, false); } } + } catch (Throwable e) { + ExceptionUtils.handleThrowable(e); + if (log.isDebugEnabled()) log.error("",e); + } + try { handler.release(socket); - try { - if (socket.getSocket() != null) { - socket.getSocket().close(true); - } - } catch (Exception e){ - if (log.isDebugEnabled()) { - log.debug(sm.getString( - "endpoint.debug.socketCloseFail"), e); + } catch (Throwable e) { + ExceptionUtils.handleThrowable(e); + if (log.isDebugEnabled()) log.error("",e); + } + try { + if (socket.getSocket() != null) { + synchronized (socket.getSocket()) { + if (socket.getSocket() != null && socket.getSocket().isOpen()) { + countDownConnection(); + socket.getSocket().close(true); + } } } + } catch (Exception e){ + if (log.isDebugEnabled()) { + log.debug(sm.getString( + "endpoint.debug.socketCloseFail"), e); + } + } + try { Nio2SocketWrapper nio2Socket = (Nio2SocketWrapper) socket; - try { - if (nio2Socket.getSendfileData() != null - && nio2Socket.getSendfileData().fchannel != null - && nio2Socket.getSendfileData().fchannel.isOpen()) { - nio2Socket.getSendfileData().fchannel.close(); - } - } catch (Exception ignore) { + if (nio2Socket.getSendfileData() != null + && nio2Socket.getSendfileData().fchannel != null + && nio2Socket.getSendfileData().fchannel.isOpen()) { + nio2Socket.getSendfileData().fchannel.close(); } - countDownConnection(); } catch (Throwable e) { ExceptionUtils.handleThrowable(e); if (log.isDebugEnabled()) log.error("",e); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org