Hi,

In Tomcat 3.2b6 there's a race condition during servlet init - if a second
request arrives while a servlet is still in its init method from its first
request, the ServletWrapper will create another instance of the servlet and
pass the new request to it without calling init, in violation of the
servlets API.  Obviously this only affects certain servlets under certain
scenarios.  It causes parts of my application to lock up sometimes.

Here's a patchfile for
jakarta-tomcat/src/share/org/apache/tomcat/core/Handler.java which fixes the
problem cleanly.

This bug has been reported in Bugrat for release 3.1, and I've tried to
report it for 3.2b6, but unfortunately BugRat is performing very badly at
the moment (Iocking up frequently), and has some serious HCI problems (i.e.
if you miss out a mandatory field in the report form and have to go back to
fix it, your entries are lost.)  It's taken me longer to try (without
success) to report the bug properly than it did to come up with the fix.

Anyway, I'm not a mailing list subscriber though I did check the archive to
see if there was reference to this problem.  So feel free to contact me
directly.  I hope the patch helps.

-Robin Barooah
[EMAIL PROTECTED]
--- Copy of Handler.java        Mon Oct  9 06:07:00 2000
+++ Handler.java        Sat Oct 28 19:57:49 2000
@@ -238,20 +238,22 @@
      */
     public void service(Request req, Response res) 
     {
-       if( ! initialized ) {
-           try {
-               init();
-               if ( ! initialized )
+       synchronized( this ) {
+           if( ! initialized ) {
+               try {
+                   init();
+                   if ( ! initialized )
                        return; // return if still not initialied
-           } catch( Exception ex ) {
-               initialized=false;
-               if( ex instanceof ClassNotFoundException ) {
-                   contextM.handleStatus( req, res, 404);
+               } catch( Exception ex ) {
+                   initialized=false;
+                   if( ex instanceof ClassNotFoundException ) {
+                       contextM.handleStatus( req, res, 404);
+                       return;
+                   }
+                   context.log("Exception in init  " + ex.getMessage(), ex );
+                   contextM.handleError( req, res, ex );
                    return;
                }
-               context.log("Exception in init  " + ex.getMessage(), ex );
-               contextM.handleError( req, res, ex );
-               return;
            }
        }
 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to