larryi 02/01/30 20:16:47 Modified: src/share/org/apache/tomcat/modules/server Http10Interceptor.java Log: Reworking the "delay" kluge for test software in which client and server run on the same system and experience "Socket reset by peer" errors due to unfavorable sequencing of thread execution. This update was needed because adding the sleep(0) caused the failure rate of Tomcat 3.3 tests under Cactus to go from infrequently to frequently on the primary Gump system running Linux. Changed delaySocketClose to closeSocketDelay and made the attribute numeric. The default is -1, which adds no delay. A value of 0, adds a Thread.yield() prior to closing the socket. A value greater than 1 causes CPU cycles to be eaten for the specified number of milliseconds prior to closing the socket. Using Thread.sleep(n) proved to be unhelpful on RH Linux 7.1. Revision Changes Path 1.31 +17 -11 jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java Index: Http10Interceptor.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- Http10Interceptor.java 25 Jan 2002 04:09:10 -0000 1.30 +++ Http10Interceptor.java 31 Jan 2002 04:16:47 -0000 1.31 @@ -100,7 +100,7 @@ { private int timeout = 300000; // 5 minutes as in Apache HTTPD server private String reportedname; - private boolean delaySocketClose = false; + private int socketCloseDelay = -1; public Http10Interceptor() { super(); @@ -123,8 +123,8 @@ reportedname = reportedName; } - public void setDelaySocketClose(boolean b) { - delaySocketClose=b; + public void setSocketCloseDelay(int d) { + socketCloseDelay=d; } public void setProperty( String prop, String value ) { @@ -208,14 +208,20 @@ log( "Error reading request, ignored", e, Log.ERROR); } finally { - // When running tests against Tomcat on the same - // system, we may need to force a thread switch - // before closing the socket to give the other - // end of the connection a chance to run - if( delaySocketClose ) { - try { - Thread.sleep(0); - } catch (InterruptedException ie) { /* ignore */ } + // When running tests against Tomcat on the same system, + // we may need to add a delay before closing the socket + // to give the other end of the connection a chance to run + if( socketCloseDelay >= 0 ) { + if( socketCloseDelay > 0 ) { + // if delay is specified, spin for that amount of time + // Note: using Thread.sleep(n) exacerbates the problem on + // RH Linux 7.1 and maybe others + long target = System.currentTimeMillis() + socketCloseDelay; + while( target <= System.currentTimeMillis()) + ; + } else { + Thread.yield(); + } } // recycle kernel sockets ASAP
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>