Switched the WebServer to detecting which flags to apply to a socket based on whether there is a pending write or remaining byte in the encrypted write buffer (likely a cause of the bug).

This commit is contained in:
wcrisman
2014-12-07 20:33:18 -08:00
parent d0360ad252
commit 866e8d8bbd

View File

@@ -1934,7 +1934,7 @@ public class WebServer {
* @see com.foundation.web.server.WebServer.AbstractSocketContext#hasPendingWrite()
*/
protected boolean hasPendingWrite() {
return pendingOutboundMessage != null;
return pendingOutboundMessage != null || (encryptedWriteBuffer != null && encryptedWriteBuffer.hasRemaining());
}//hasPendingWrite()//
/* (non-Javadoc)
* @see com.foundation.web.interfaces.IConnectionContext#upgradeToWebsocket(java.lang.String, long, com.foundation.web.interfaces.WebsocketHandler)
@@ -2252,8 +2252,8 @@ public class WebServer {
synchronized(selectionKey) {
if(selectionKey.isValid()) {
//Always flag the socket for reading, only flag the socket for writing if a pending write operation exists.//
//selectionKey.interestOps(SelectionKey.OP_READ | (((AbstractSocketContext) context).hasPendingWrite() ? SelectionKey.OP_WRITE : 0));
selectionKey.interestOps(((AbstractSocketContext) context).flags);
selectionKey.interestOps(SelectionKey.OP_READ | (((AbstractSocketContext) context).hasPendingWrite() ? SelectionKey.OP_WRITE : 0));
//selectionKey.interestOps(((AbstractSocketContext) context).flags);
}//if//
else {
Debug.log(new RuntimeException("Woops! Somehow the selection key isn't valid, but the socket isn't closed either!"));