343923 flush timeouts applied to outer loop

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@3034 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Greg Wilkins 2011-04-27 23:17:17 +00:00
parent 3b6dd2778b
commit 7227f8c6bb
3 changed files with 19 additions and 9 deletions

View File

@ -6,6 +6,7 @@ jetty-7.4.1-SNAPSHOT
+ 343567 HttpClient does not limit the destination's exchange queue + 343567 HttpClient does not limit the destination's exchange queue
+ 343707 'REQUEST' is printed on console for each incoming HTTP request + 343707 'REQUEST' is printed on console for each incoming HTTP request
+ 343482 refactored overlay deployer layout to use WAR layout + 343482 refactored overlay deployer layout to use WAR layout
+ 343923 flush timeouts applied to outer loop
jetty-7.4.0.v20110414 jetty-7.4.0.v20110414
+ 342504 Scanner Listener + 342504 Scanner Listener

View File

@ -424,22 +424,28 @@ public abstract class AbstractGenerator implements Generator
public void flush(long maxIdleTime) throws IOException public void flush(long maxIdleTime) throws IOException
{ {
// block until everything is flushed // block until everything is flushed
long now=System.currentTimeMillis();
long end=now+maxIdleTime;
Buffer content = _content; Buffer content = _content;
Buffer buffer = _buffer; Buffer buffer = _buffer;
if (content!=null && content.length()>0 || buffer!=null && buffer.length()>0 || isBufferFull()) if (content!=null && content.length()>0 || buffer!=null && buffer.length()>0 || isBufferFull())
{ {
flushBuffer(); flushBuffer();
while ((content!=null && content.length()>0 ||buffer!=null && buffer.length()>0) && _endp.isOpen()) while (now<end && (content!=null && content.length()>0 ||buffer!=null && buffer.length()>0) && _endp.isOpen())
blockForOutput(maxIdleTime); {
blockForOutput(end-now);
now=System.currentTimeMillis();
}
} }
// make sure buffered data is also flushed // make sure buffered data is also flushed
while (_endp.isBufferingOutput() && _endp.isOpen()) while (now<end && _endp.isBufferingOutput() && _endp.isOpen())
{ {
if (!_endp.isBlocking()) if (!_endp.isBlocking())
_endp.blockWritable(maxIdleTime); _endp.blockWritable(end-now);
_endp.flush(); _endp.flush();
now=System.currentTimeMillis();
} }
} }

View File

@ -354,7 +354,8 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
{ {
synchronized (this) synchronized (this)
{ {
long start=_selectSet.getNow(); long now=_selectSet.getNow();
long end=now+timeoutMs;
try try
{ {
_writeBlocked=true; _writeBlocked=true;
@ -363,15 +364,17 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
try try
{ {
updateKey(); updateKey();
this.wait(timeoutMs); this.wait(end-now);
} }
catch (InterruptedException e) catch (InterruptedException e)
{ {
Log.warn(e); Log.warn(e);
} }
finally
timeoutMs -= _selectSet.getNow()-start; {
if (_writeBlocked && timeoutMs<=0) now=_selectSet.getNow();
}
if (_writeBlocked && now>=end)
return false; return false;
} }
} }