306884 handle timeouts <=0 for suspend

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1407 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Greg Wilkins 2010-03-23 22:57:45 +00:00
parent b5654648eb
commit a21a29b6a9
3 changed files with 28 additions and 21 deletions

View File

@ -1,6 +1,7 @@
jetty-7.0.2.SNAPSHOT
+ 306783 - NPE in StdErrLog when Throwable is null
+ 306840 - Suppress content-length in requests with no content
+ 306884 - Suspend with timeout <=0 never expires
jetty-7.0.2.RC0
+ JSON parses NaN as null

View File

@ -147,7 +147,8 @@ public interface Continuation
*
* @param timeoutMs
* The time in milliseconds to wait before expiring this
* continuation after a call to {@link #suspend()} or {@link #suspend(ServletResponse)}
* continuation after a call to {@link #suspend()} or {@link #suspend(ServletResponse)}.
* A timeout of <=0 means the continuation will never expire.
*/
void setTimeout(long timeoutMs);

View File

@ -544,33 +544,38 @@ public class AsyncContinuation implements AsyncContext, Continuation
protected void scheduleTimeout()
{
EndPoint endp=_connection.getEndPoint();
if (endp.isBlocking())
if (_timeoutMs>0)
{
synchronized(this)
if (endp.isBlocking())
{
_expireAt = System.currentTimeMillis()+_timeoutMs;
long wait=_timeoutMs;
while (_expireAt>0 && wait>0)
synchronized(this)
{
try
_expireAt = System.currentTimeMillis()+_timeoutMs;
long wait=_timeoutMs;
while (_expireAt>0 && wait>0)
{
this.wait(wait);
try
{
this.wait(wait);
}
catch (InterruptedException e)
{
Log.ignore(e);
}
wait=_expireAt-System.currentTimeMillis();
}
catch (InterruptedException e)
{
Log.ignore(e);
}
wait=_expireAt-System.currentTimeMillis();
}
if (_expireAt>0 && wait<=0)
{
expired();
}
}
if (_expireAt>0 && wait<=0)
{
expired();
}
}
}
else
{
_connection.scheduleTimeout(_event,_timeoutMs);
}
}
else
_connection.scheduleTimeout(_event,_timeoutMs);
}
/* ------------------------------------------------------------ */