tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ralph Einfeldt" <ralph.einfe...@uptime-isc.de>
Subject RE: Tomcat5 and Servlet Timeout: Possible?
Date Wed, 08 Sep 2004 10:09:51 GMT

You may try following snippet as a base for a filter.
(I havn't tried it in a filter chain, so no garantee)

<Filter>
InterruptTimer mTimer = new InterruptTimer(5000, 10);
mTimer.start();
try {

  doChain() // Don't have the correct syntax at hand...

} catch (??InterruptedIOException?? ex) {

  // Log what you think to be helpfull

}
mTimer.reset();
</Filter>


public class InterruptTimer extends Thread {
    long oEndTime = 0;
    int oSleepTime = 10;
    Thread oStartingThread = Thread.currentThread();
    Thread oRunningThread = null;

    public InterruptTimer(int aLength, int aSleepTime) {
        // Both times are in ms
        oSleepTime = aSleepTime;
        oEndTime = System.currentTimeMillis() + aLength;
    }
    
    public void run() {
        oRunningThread = Thread.currentThread();
        // Loop until the end time is reached or reset() was called.
        while (System.currentTimeMillis() < oEndTime) {
            try { 
                Thread.sleep(oSleepTime);
            } catch (InterruptedIOException ex) {
            }
        }
        if (oEndTime > 0) {
            timeout();
        }
    }
    public void reset() {
        oEndTime = 0;
    }

    public void timeout() {
        oStartingThread.interrupt();
    }
}

> -----Original Message-----
> From: news [mailto:news@sea.gmane.org]On Behalf Of Andreas Schildbach
> Sent: Tuesday, September 07, 2004 9:19 PM
> To: tomcat-user@jakarta.apache.org
> Subject: Re: Tomcat5 and Servlet Timeout: Possible?
> 
> 
> Shapira, Yoav wrote:
> 
> > There's no such option in Tomcat.
> 
> So if one thread hangs, it hangs forever.
> 
> If it blocks other threads, the whole app hangs...
> 
> Regards,
> 
> Andreas
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 
> 

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


Mime
View raw message