shishkovilja commented on code in PR #12574:
URL: https://github.com/apache/ignite/pull/12574#discussion_r2694438436
##########
modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java:
##########
@@ -192,37 +194,26 @@ <T> T readMessage() throws IgniteCheckedException,
IOException {
if (read == -1)
throw new EOFException("Connection closed before message
was fully read.");
- if (msgBuf.position() > 0) {
- msgBuf.limit(msgBuf.position() + read);
-
- // We've stored an unprocessed tail before.
- msgBuf.rewind();
- }
- else
- msgBuf.limit(read);
+ msgBuf.limit(read);
finished = msgSer.readFrom(msg, msgReader);
- // We rely on the fact that Discovery only sends next message
upon receiving a receipt for the previous one.
+ // Server Discovery only sends next message to next Server
upon receiving a receipt for the previous one.
// This behaviour guarantees that we never read a next message
from the buffer right after the end of
- // the previous message.
- assert msgBuf.remaining() == 0 || !finished : "Some data was
read from the socket but left unprocessed.";
-
- if (finished)
- break;
+ // the previous message. But it is not guaranteed with Client
Discovery where messages aren't acknowledged.
+ // Thus, we have to keep the uprocessed bytes read from the
socket. It won't return them again.
+ if (msgBuf.remaining() > 0) {
Review Comment:
`msgBuffer.hasRemaining()` ?
##########
modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java:
##########
@@ -192,37 +194,26 @@ <T> T readMessage() throws IgniteCheckedException,
IOException {
if (read == -1)
throw new EOFException("Connection closed before message
was fully read.");
- if (msgBuf.position() > 0) {
- msgBuf.limit(msgBuf.position() + read);
-
- // We've stored an unprocessed tail before.
- msgBuf.rewind();
- }
- else
- msgBuf.limit(read);
+ msgBuf.limit(read);
finished = msgSer.readFrom(msg, msgReader);
- // We rely on the fact that Discovery only sends next message
upon receiving a receipt for the previous one.
+ // Server Discovery only sends next message to next Server
upon receiving a receipt for the previous one.
// This behaviour guarantees that we never read a next message
from the buffer right after the end of
- // the previous message.
- assert msgBuf.remaining() == 0 || !finished : "Some data was
read from the socket but left unprocessed.";
-
- if (finished)
- break;
+ // the previous message. But it is not guaranteed with Client
Discovery where messages aren't acknowledged.
+ // Thus, we have to keep the uprocessed bytes read from the
socket. It won't return them again.
+ if (msgBuf.remaining() > 0) {
Review Comment:
`msgBuf.hasRemaining()` ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]