tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Krešimir Pavić <Kresimir.Pa...@iskon.hr>
Subject CGIRunner (at CGIServlet) problem
Date Wed, 13 Oct 2004 16:36:57 GMT
Hi!

  I've found a problem in CGI module (servlets-cgi.jar) in Tomcat distribution.
  The problem occures in some occasions that are hard to reproduce. 
  We have Tomcat that invokes some CGI (webmail) on Linux (Debian).
  Everthings worked fine, but
  after few days we discoverd lots of cgi programms that are hanged in WRITE mode.
  So after a week, we needed fast restart of Tomcat (OutOfMemoryError -> hanging 
  forked proceses).

  Problem was detected in next few line (thread that reads from forked process and
  wirites data to client). In few occasions we catched this exception:
   java.net.SocketExcpetion: ClientAbortException (in code below)
  and our forked process didn't finish
  his work and remained hanging (in write mode ), but sometimes we got this exception:
   java.net.SocketException: Broken pipe (in catalina.out) and forked process finished 
  his work as supposed.
  Both exceptions are thrown wheb client closes his/her browser before anthing appears.
  First excpetion is very hard to reproduce (try it :-).

  The solution is to add try-catch block in while loop. With this modification, any
  forked process will finish his work and be able to write the complete content 
  (somewhere).

  while ((bufRead = commandsStdOut.read(cBuf)) != -1) {
   if (servletContainerStdout != null) {
      if (debug >= 4) {
         log("runCGI: write(\"" + new String(cBuf, 0, bufRead) + "\")");
      }

      /////////////////////////////
      // new code

      try {
        servletContainerStdout.write(cBuf, 0, bufRead); // old line
      } catch (java.net.SocketException se {
      servletContainerStdout = null;

      // end of new code
      ////////////////////////

   }
  }

              kresimir

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message