ENT-12414: New network protocol v4 - SAFEGET #5621
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The current protocol (v3) uses a
STAT <FILENAME>
request to determine the file size (among other things), followed by aGET <FILENAME>
request to fetch the file content. However, there is a race condition here. If the file size increases between the two requests, the client would think that the remaining data after the "file size" offset is a new response header.Here, we introduce a new protocol-version "safeget" to address the race condition. PDUs from the response following a
GET <FILENAME>
request now contain a protocol header consisting of a NULL-byte terminated string of four unsigned integers (uint64_t
). We will refer to the four integers as ERROR_CODE, FILE_SIZE, FILE_OFFSET, and PAYLOAD_SIZE. The integers will appear in this order in the protocol header. Each integer is separated by a whitespace character.A non-zero ERROR_CODE signals that an error occurred. Furthermore, the exact value of ERROR_CODE specifies what went wrong on the server side. FILE_SIZE and FILE_OFFSET are mainly used to determine when the last PDU is received (i.e., when FILE_SIZE = FILE_OFFSET + PAYLOAD_SIZE). However, FILE_SIZE is also used to detect if the file is modified at the source during transmission. The payload starts immediately after the NULL-terminating byte in the protocol header and consists of PAYLOAD_SIZE bytes.