307898 websocket connection returns if no progress

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1435 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Greg Wilkins 2010-04-01 16:49:03 +00:00
parent 54117dad5b
commit 012b1e7c22
2 changed files with 7 additions and 7 deletions

View File

@ -87,24 +87,22 @@ public class WebSocketConnection implements Connection, WebSocket.Outbound
public Connection handle() throws IOException public Connection handle() throws IOException
{ {
boolean more=true; boolean progress=true;
try try
{ {
while (more) while (progress)
{ {
int flushed=_generator.flush(); int flushed=_generator.flush();
int filled=_parser.parseNext(); int filled=_parser.parseNext();
// TODO remove this potential busy loop. more should be true if content was parsed even if no bytes were filled! progress = flushed>0 || filled>0;
more = flushed>0 || filled>0 || !_parser.isBufferEmpty();
if (filled<0 || flushed<0) if (filled<0 || flushed<0)
{ {
_endp.close(); _endp.close();
break; break;
} }
} }
} }
catch(IOException e) catch(IOException e)

View File

@ -63,7 +63,9 @@ public class WebSocketParser
/** Parse to next event. /** Parse to next event.
* Parse to the next {@link EventHandler} event or until no more data is * Parse to the next {@link EventHandler} event or until no more data is
* available. Fill data from the {@link EndPoint} only as necessary. * available. Fill data from the {@link EndPoint} only as necessary.
* @return total bytes filled or -1 for EOF * @return An indication of progress or otherwise. -1 indicates EOF, 0 indicates
* that no bytes were read and no messages parsed. A positive number indicates either
* the bytes filled or the messages parsed.
*/ */
public int parseNext() public int parseNext()
{ {
@ -172,7 +174,7 @@ public class WebSocketParser
_buffer=null; _buffer=null;
} }
return total_filled; return 1; // the number of messages handled.
} }
} }
} }