Widen speed limit types from uint16 to uint32#436
Open
got3nks wants to merge 2 commits intoamule-project:masterfrom
Open
Widen speed limit types from uint16 to uint32#436got3nks wants to merge 2 commits intoamule-project:masterfrom
got3nks wants to merge 2 commits intoamule-project:masterfrom
Conversation
The upload/download speed limits (s_maxupload, s_maxdownload) and slot allocation (s_slotallocation) were stored as uint16, capping configurable speed to 65534 kB/s (~524 Mbps) since 65535 is treated as unlimited. This is inadequate for modern gigabit+ connections. Changes: Preferences.h / Preferences.cpp: - Change s_maxupload, s_maxdownload, s_slotallocation from uint16 to uint32, along with their getters and setters - The existing backwards compatibility check in CheckUlDlRatio() that maps 0xFFFF to UNLIMITED still works correctly with uint32 UploadQueue.h / UploadQueue.cpp: - Change GetMaxSlots() return type and local variables from uint16 to uint32 to prevent truncation when calculating slot counts from large speed values RemoteConnect.h: - Update SetPreferencesConnections() parameter types for MaxDownloadSpeed, MaxUploadSpeed, and UploadSlotAllocation from uint16 to uint32 EC protocol note: - EC tags EC_TAG_CONN_MAX_UL, EC_TAG_CONN_MAX_DL, and EC_TAG_CONN_SLOT_ALLOCATION now carry uint32 values. EC clients reading these tags should use GetInt() which handles any integer size. Clients sending these tags should encode them as 32-bit.
|
There is a documentation for the EC protocol. Maybe is great to add this change to the doc in order to keep it current. |
Add Section 4 with a tag type reference for EC_TAG_PREFS_CONNECTIONS subtags, noting that EC_TAG_CONN_MAX_DL, EC_TAG_CONN_MAX_UL, and EC_TAG_CONN_SLOT_ALLOCATION were widened from uint16 to uint32. Requested by reviewer on PR#436.
Contributor
Author
|
Good call, thank you! Added a new Section 4: Notable Tag Types to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
The upload/download speed limits (
s_maxupload,s_maxdownload) and slot allocation (s_slotallocation) are stored asuint16, capping the configurable speed to 65534 kB/s (~524 Mbps) since 65535 is treated as unlimited. This is inadequate for modern gigabit+ connections.s_maxupload,s_maxdownload,s_slotallocationfromuint16touint32inPreferences.h/Preferences.cpp, along with their getters and settersGetMaxSlots()return type and local variables fromuint16touint32to prevent truncation when calculating slot counts from large speed valuesSetPreferencesConnections()parameter types inRemoteConnect.hBackward compatibility
CheckUlDlRatio()that maps0xFFFFtoUNLIMITEDstill works correctly withuint32MkCfg_Intis templated and handlesuint32without changesMAX_UP_CLIENTS_ALLOWEDremains at 250 (unchanged)EC protocol note
EC tags
EC_TAG_CONN_MAX_UL,EC_TAG_CONN_MAX_DL, andEC_TAG_CONN_SLOT_ALLOCATIONnow carryuint32values. TheApply()method usesoneTag->GetInt()which handles any integer size. EC clients sending these tags should encode them as 32-bit integers.Files changed
src/Preferences.hsrc/Preferences.cppsrc/UploadQueue.hGetMaxSlots()return typesrc/UploadQueue.cppGetMaxSlots()implementation + local varssrc/libs/ec/cpp/RemoteConnect.h