Skip to content

Commit

Permalink
#25 Fix bug in TCPTransport receive buffer processing. Deployed bug fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
simondelabici committed Jun 18, 2018
1 parent f4bcbfd commit e6f9088
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/main/java/org/epics/ca/impl/TCPTransport.java
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,6 @@ else if (bytesRead == 0)
// and sets the position back to zero again.
logger.log( Level.FINEST,"Flipping buffer." );
receiveBuffer.flip();
logger.log( Level.FINEST,"cmd is: " + String.valueOf( receiveBuffer.get( 0 ) ) );
logger.log( Level.FINEST,"ReceiveBuffer now has #bytes: " + String.valueOf( receiveBuffer.remaining() ) );

// Now go ahead and try to process whatever data we have obtained
Expand Down Expand Up @@ -431,7 +430,7 @@ protected void processReadBuffer()
break;
}

// If we get here then we have enough room to read the payload and the data is already present :-)
// If we get here then we have enough room to read the payload and the data is already present :-)
// in the buffer. We now have all the information needed to process the current message so go and
// do it.

Expand Down Expand Up @@ -467,11 +466,11 @@ protected void processReadBuffer()
// to receive new data.

logger.log( Level.FINEST, "Checking for any remaining bytes." );
if (receiveBuffer.hasRemaining())
int unprocessedBytes = receiveBuffer.limit() - lastMessageStartPosition;
if ( unprocessedBytes > 0 )
{
// copy remaining buffer, lastMessageBytesAvailable bytes from lastMessagePosition,
// to the start of receiveBuffer
int unprocessedBytes = receiveBuffer.limit() - lastMessageStartPosition;
logger.log( Level.FINEST, "- moving remaining bytes to start of buffer. Unprocessed bytes = " + String.valueOf( unprocessedBytes ) );
if (unprocessedBytes < 1024)
{
Expand Down

0 comments on commit e6f9088

Please sign in to comment.