tomcat-dev mailing list archives

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

  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: 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: 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 

  while ((bufRead = != -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 ( se {
      servletContainerStdout = null;

      // end of new code



To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message