Avoid flush if no content to flush
This commit is contained in:
parent
f37b617481
commit
921b285235
|
@ -22,6 +22,8 @@ import java.nio.channels.ByteChannel;
|
||||||
import java.nio.channels.GatheringByteChannel;
|
import java.nio.channels.GatheringByteChannel;
|
||||||
import java.nio.channels.SelectableChannel;
|
import java.nio.channels.SelectableChannel;
|
||||||
import java.nio.channels.SocketChannel;
|
import java.nio.channels.SocketChannel;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
|
||||||
import org.eclipse.jetty.io.Buffer;
|
import org.eclipse.jetty.io.Buffer;
|
||||||
import org.eclipse.jetty.io.EndPoint;
|
import org.eclipse.jetty.io.EndPoint;
|
||||||
|
|
|
@ -1145,11 +1145,11 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
|
||||||
{
|
{
|
||||||
BufferedReader br=null;
|
BufferedReader br=null;
|
||||||
|
|
||||||
|
StringBuilder sb=new StringBuilder();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
br=new BufferedReader(new InputStreamReader(client.getInputStream()));
|
br=new BufferedReader(new InputStreamReader(client.getInputStream()));
|
||||||
|
|
||||||
StringBuilder sb=new StringBuilder();
|
|
||||||
String line;
|
String line;
|
||||||
|
|
||||||
while ((line=br.readLine())!=null)
|
while ((line=br.readLine())!=null)
|
||||||
|
@ -1160,6 +1160,11 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
catch(IOException e)
|
||||||
|
{
|
||||||
|
System.err.println(e+" while reading '"+sb+"'");
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
if (br!=null)
|
if (br!=null)
|
||||||
|
|
|
@ -247,13 +247,17 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc
|
||||||
int filled=_parser.parseNext();
|
int filled=_parser.parseNext();
|
||||||
|
|
||||||
progress = flushed>0 || filled>0;
|
progress = flushed>0 || filled>0;
|
||||||
|
|
||||||
|
if (_endp instanceof AsyncEndPoint && ((AsyncEndPoint)_endp).hasProgressed())
|
||||||
|
progress=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(IOException e)
|
catch(IOException e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_endp.close();
|
if (_endp.isOpen())
|
||||||
|
_endp.close();
|
||||||
}
|
}
|
||||||
catch(IOException e2)
|
catch(IOException e2)
|
||||||
{
|
{
|
||||||
|
|
|
@ -190,7 +190,7 @@ public class WebSocketGeneratorD13 implements WebSocketGenerator
|
||||||
|
|
||||||
if (_buffer!=null)
|
if (_buffer!=null)
|
||||||
{
|
{
|
||||||
int flushed=_endp.flush(_buffer);
|
int flushed=_buffer.hasContent()?_endp.flush(_buffer):0;
|
||||||
if (_closed&&_buffer.length()==0)
|
if (_closed&&_buffer.length()==0)
|
||||||
_endp.shutdownOutput();
|
_endp.shutdownOutput();
|
||||||
return flushed;
|
return flushed;
|
||||||
|
|
|
@ -19,6 +19,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import org.eclipse.jetty.io.Buffer;
|
import org.eclipse.jetty.io.Buffer;
|
||||||
import org.eclipse.jetty.io.ByteArrayEndPoint;
|
import org.eclipse.jetty.io.ByteArrayEndPoint;
|
||||||
|
import org.eclipse.jetty.io.nio.ChannelEndPoint;
|
||||||
import org.eclipse.jetty.server.Connector;
|
import org.eclipse.jetty.server.Connector;
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||||
|
@ -1122,17 +1123,25 @@ public class WebSocketMessageD13Test
|
||||||
else
|
else
|
||||||
assertEquals(tst,tests[t][2],-1);
|
assertEquals(tst,tests[t][2],-1);
|
||||||
|
|
||||||
output.write(0x88);
|
try
|
||||||
output.write(0x80);
|
{
|
||||||
output.write(0x00);
|
output.write(0x88);
|
||||||
output.write(0x00);
|
output.write(0x80);
|
||||||
output.write(0x00);
|
output.write(0x00);
|
||||||
output.write(0x00);
|
output.write(0x00);
|
||||||
output.flush();
|
output.write(0x00);
|
||||||
|
output.write(0x00);
|
||||||
|
output.flush();
|
||||||
|
}
|
||||||
|
catch(IOException e)
|
||||||
|
{
|
||||||
|
System.err.println("socket "+socket);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
len = input.read(buf);
|
len = input.read(buf);
|
||||||
assertEquals(tst,-1,len);
|
assertEquals(tst,-1,len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue