roq-trading / roq-issues

Issue tracker for Roq's software solutions.
https://roq-trading.com/
1 stars 0 forks source link

[roq-cme] TCP fragmentation could cause freeze #392

Closed thraneh closed 1 year ago

thraneh commented 1 year ago

iLink SBE parsing incorrectly assumed messages were received in full.

The socket read code was based on MDP SBE parsing which is based on UDP where datagrams are received in full (or nothing at all). Fragmentation is not possible.

However, iLink is based on TCP where messages are allowed to be fragmented (by the TCP stream protocol).

Symptoms:

Reason:

Message parsing happens inside a loop that processes the read stream buffer. When the parser failed (due to message length) it would return 0 (bytes) to indicate that the read buffer did not yet have enough data. Unfortunately, the loop would only check on read buffer being fully processed by checking when the read buffer became empty. This resulted in an infinite loop.

Solution:

Break the loop when not enough data is ready to process the next message.