Fixed bug in the internalProcessResponses() in SocketContext where a message was flagged as needing to send more data because of already encrypted but unsent data, but was not properly sending the data because the currentOutboundMessage was closed and cleared.

This commit is contained in:
wcrisman
2014-12-28 17:09:06 -08:00
parent 0c3b7d026b
commit d1d5671229

View File

@@ -726,26 +726,32 @@ private void loadNextWebsocketMessage() {
* @return
*/
private synchronized void internalProcessResponses() {
boolean finishedSending = true;
boolean doneSending = false;
//Keep sending responses while the buffers are not full and there is another response to send.//
while(finishedSending) {
while(!doneSending) {
boolean messageSent = true;
//If the socket is open then send the next buffer of data.//
if(key.channel().isOpen()) {
//Send the pending response object's prepared buffer of data.//
finishedSending = writeClientBoundMessage();
messageSent = writeClientBoundMessage();
}//if//
//Close the response if successfully sent, or if the socket is closed.//
if(finishedSending || !key.channel().isOpen()) {
if((messageSent || !key.channel().isOpen()) && currentOutboundMessage != null) {
try {currentOutboundMessage.close();} catch(Throwable e) {}
}//if//
//If we finished sending the current response then load the next one.//
if(finishedSending) {
if(messageSent) {
//TODO: Queue up the next outbound message.
currentOutboundMessage = null;
}//if//
if(currentOutboundMessage == null) {
doneSending = true;
}//if//
}//while//
// //Keep sending responses while the buffers are not full and there is another response to send.//