Skip to content

Widen speed limit types from uint16 to uint32 - #436

Merged
mrjimenez merged 2 commits into
amule-project:masterfrom
got3nks:pr/widen-speed-limits
Apr 22, 2026
Merged

Widen speed limit types from uint16 to uint32#436
mrjimenez merged 2 commits into
amule-project:masterfrom
got3nks:pr/widen-speed-limits

Conversation

@got3nks

@got3nks got3nks commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

Summary

The upload/download speed limits (s_maxupload, s_maxdownload) and slot allocation (s_slotallocation) are stored as uint16, capping the configurable speed to 65534 kB/s (~524 Mbps) since 65535 is treated as unlimited. This is inadequate for modern gigabit+ connections.

  • Change s_maxupload, s_maxdownload, s_slotallocation from uint16 to uint32 in Preferences.h / Preferences.cpp, along with their getters and setters
  • Change GetMaxSlots() return type and local variables from uint16 to uint32 to prevent truncation when calculating slot counts from large speed values
  • Update SetPreferencesConnections() parameter types in RemoteConnect.h

Backward compatibility

  • The existing backwards compatibility check in CheckUlDlRatio() that maps 0xFFFF to UNLIMITED still works correctly with uint32
  • MkCfg_Int is templated and handles uint32 without changes
  • MAX_UP_CLIENTS_ALLOWED remains at 250 (unchanged)

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. The Apply() method uses oneTag->GetInt() which handles any integer size. EC clients sending these tags should encode them as 32-bit integers.

Files changed

File Changes
src/Preferences.h Type widening for declarations, getters, setters
src/Preferences.cpp Static definitions + setter implementations
src/UploadQueue.h GetMaxSlots() return type
src/UploadQueue.cpp GetMaxSlots() implementation + local vars
src/libs/ec/cpp/RemoteConnect.h EC client method parameter types

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.
@frnjjq

frnjjq commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

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.
@got3nks

got3nks commented Apr 8, 2026

Copy link
Copy Markdown
Contributor Author

Good call, thank you! Added a new Section 4: Notable Tag Types to docs/EC_Protocol.txt that documents the data types of all EC_TAG_PREFS_CONNECTIONS subtags and calls out the uint16 → uint32 widening for EC_TAG_CONN_MAX_DL, EC_TAG_CONN_MAX_UL, and EC_TAG_CONN_SLOT_ALLOCATION.

@mrjimenez
mrjimenez merged commit 4948859 into amule-project:master Apr 22, 2026
2 checks passed
got3nks added a commit to got3nks/amule that referenced this pull request Apr 23, 2026
Two small UI fixes on the Preferences dialog:

1. **Bandwidth spin caps: 19375 kB/s → 1000000 kB/s**

   The four bandwidth spin controls in src/muuli_wdr.cpp were still
   capped at 19375 kB/s (~155 Mbit/s), a floor from the pre-
   gigabit-Ethernet era. Users on gigabit or multi-gig links saw the
   value silently clamp when they typed anything higher. amule-project#436 has
   already widened MaxUpload / MaxDownload prefs to uint32, and the
   upload throttler's bytesToSpend arithmetic (sint32 accumulator
   ticking at ~1 kHz) still has ~2 seconds of headroom before
   overflow at 1 GB/s, so 1000000 is a safe modern ceiling.

   Fields touched:
     IDC_MAXDOWN, IDC_MAXUP           — Connection page
     IDC_DOWNLOAD_CAP, IDC_UPLOAD_CAP — Statistics graph scale

2. **wxSpinCtrl width: hardcoded wxSize(100,-1) → wxDefaultSize**

   On GTK 3 (and likely other modern themes) the hardcoded 100 px
   width is too narrow for wxSpinCtrl to render both spin buttons
   when the value field contains 5+ digits. The + button ends up
   clipped / cut off visually on the Connection, Security and other
   prefs pages. wxDefaultSize lets wx compute a width that fits the
   text + both buttons based on theme font metrics. 16 spin controls
   updated; the few narrower ones (wxSize(40,-1), wxSize(45,-1),
   wxSize(60,-1) for single- or few-digit fields) are intentionally
   left alone.
got3nks added a commit to got3nks/amule that referenced this pull request Apr 23, 2026
Two small UI fixes on the Preferences dialog:

1. **Bandwidth spin caps: 19375 kB/s → 1000000 kB/s**

   The four bandwidth spin controls in src/muuli_wdr.cpp were still
   capped at 19375 kB/s (~155 Mbit/s), a floor from the pre-
   gigabit-Ethernet era. Users on gigabit or multi-gig links saw the
   value silently clamp when they typed anything higher. amule-project#436 has
   already widened MaxUpload / MaxDownload prefs to uint32, and the
   upload throttler's bytesToSpend arithmetic (sint32 accumulator
   ticking at ~1 kHz) still has ~2 seconds of headroom before
   overflow at 1 GB/s, so 1000000 is a safe modern ceiling.

   Fields touched:
     IDC_MAXDOWN, IDC_MAXUP           — Connection page
     IDC_DOWNLOAD_CAP, IDC_UPLOAD_CAP — Statistics graph scale

2. **wxSpinCtrl width: hardcoded wxSize(100,-1) → wxDefaultSize**

   On GTK 3 (and likely other modern themes) the hardcoded 100 px
   width is too narrow for wxSpinCtrl to render both spin buttons
   when the value field contains 5+ digits. The + button ends up
   clipped / cut off visually on the Connection, Security and other
   prefs pages. wxDefaultSize lets wx compute a width that fits the
   text + both buttons based on theme font metrics. 16 spin controls
   updated; the few narrower ones (wxSize(40,-1), wxSize(45,-1),
   wxSize(60,-1) for single- or few-digit fields) are intentionally
   left alone.
got3nks added a commit to got3nks/amule that referenced this pull request Apr 23, 2026
Two small UI fixes on the Preferences dialog:

1. **Bandwidth spin caps: 19375 kB/s → 1000000 kB/s**

   The four bandwidth spin controls in src/muuli_wdr.cpp were still
   capped at 19375 kB/s (~155 Mbit/s), a floor from the pre-
   gigabit-Ethernet era. Users on gigabit or multi-gig links saw the
   value silently clamp when they typed anything higher. amule-project#436 has
   already widened MaxUpload / MaxDownload prefs to uint32, and the
   upload throttler's bytesToSpend arithmetic (sint32 accumulator
   ticking at ~1 kHz) still has ~2 seconds of headroom before
   overflow at 1 GB/s, so 1000000 is a safe modern ceiling.

   Fields touched:
     IDC_MAXDOWN, IDC_MAXUP           — Connection page
     IDC_DOWNLOAD_CAP, IDC_UPLOAD_CAP — Statistics graph scale

2. **wxSpinCtrl width: hardcoded wxSize(100,-1) → wxDefaultSize**

   On GTK 3 (and likely other modern themes) the hardcoded 100 px
   width is too narrow for wxSpinCtrl to render both spin buttons
   when the value field contains 5+ digits. The + button ends up
   clipped / cut off visually on the Connection, Security and other
   prefs pages. wxDefaultSize lets wx compute a width that fits the
   text + both buttons based on theme font metrics. 16 spin controls
   updated; the few narrower ones (wxSize(40,-1), wxSize(45,-1),
   wxSize(60,-1) for single- or few-digit fields) are intentionally
   left alone.
got3nks added a commit to got3nks/amule that referenced this pull request Apr 23, 2026
Two small UI fixes on the Preferences dialog:

1. **Bandwidth spin caps: 19375 kB/s → 1000000 kB/s**

   The four bandwidth spin controls in src/muuli_wdr.cpp were still
   capped at 19375 kB/s (~155 Mbit/s), a floor from the pre-
   gigabit-Ethernet era. Users on gigabit or multi-gig links saw the
   value silently clamp when they typed anything higher. amule-project#436 has
   already widened MaxUpload / MaxDownload prefs to uint32, and the
   upload throttler's bytesToSpend arithmetic (sint32 accumulator
   ticking at ~1 kHz) still has ~2 seconds of headroom before
   overflow at 1 GB/s, so 1000000 is a safe modern ceiling.

   Fields touched:
     IDC_MAXDOWN, IDC_MAXUP           — Connection page
     IDC_DOWNLOAD_CAP, IDC_UPLOAD_CAP — Statistics graph scale

2. **wxSpinCtrl width: hardcoded wxSize(100,-1) → wxDefaultSize**

   On GTK 3 (and likely other modern themes) the hardcoded 100 px
   width is too narrow for wxSpinCtrl to render both spin buttons
   when the value field contains 5+ digits. The + button ends up
   clipped / cut off visually on the Connection, Security and other
   prefs pages. wxDefaultSize lets wx compute a width that fits the
   text + both buttons based on theme font metrics. 16 spin controls
   updated; the few narrower ones (wxSize(40,-1), wxSize(45,-1),
   wxSize(60,-1) for single- or few-digit fields) are intentionally
   left alone.
got3nks added a commit to got3nks/amule that referenced this pull request Apr 23, 2026
Two small UI fixes on the Preferences dialog:

1. **Bandwidth spin caps: 19375 kB/s → 1000000 kB/s**

   The four bandwidth spin controls in src/muuli_wdr.cpp were still
   capped at 19375 kB/s (~155 Mbit/s), a floor from the pre-
   gigabit-Ethernet era. Users on gigabit or multi-gig links saw the
   value silently clamp when they typed anything higher. amule-project#436 has
   already widened MaxUpload / MaxDownload prefs to uint32, and the
   upload throttler's bytesToSpend arithmetic (sint32 accumulator
   ticking at ~1 kHz) still has ~2 seconds of headroom before
   overflow at 1 GB/s, so 1000000 is a safe modern ceiling.

   Fields touched:
     IDC_MAXDOWN, IDC_MAXUP           — Connection page
     IDC_DOWNLOAD_CAP, IDC_UPLOAD_CAP — Statistics graph scale

2. **wxSpinCtrl width: hardcoded wxSize(100,-1) → wxDefaultSize**

   On GTK 3 (and likely other modern themes) the hardcoded 100 px
   width is too narrow for wxSpinCtrl to render both spin buttons
   when the value field contains 5+ digits. The + button ends up
   clipped / cut off visually on the Connection, Security and other
   prefs pages. wxDefaultSize lets wx compute a width that fits the
   text + both buttons based on theme font metrics. 16 spin controls
   updated; the few narrower ones (wxSize(40,-1), wxSize(45,-1),
   wxSize(60,-1) for single- or few-digit fields) are intentionally
   left alone.
got3nks added a commit to got3nks/amule that referenced this pull request Apr 23, 2026
Three small UI fixes on the Preferences dialog.

1. **Bandwidth spin caps raised from 19375 kB/s to 1,000,000 kB/s.**

   The bandwidth spin controls in src/muuli_wdr.cpp were capped at
   19375 kB/s (~155 Mbit/s), a floor from the pre-gigabit-Ethernet era.
   Users on gigabit or multi-gig links saw the value silently clamp
   when they typed anything higher. amule-project#436 has already widened MaxUpload /
   MaxDownload prefs to uint32, and the upload throttler's bytesToSpend
   arithmetic (sint32 accumulator ticking at ~1 kHz) still has ~2
   seconds of headroom before overflow at 1 GB/s, so 1,000,000 is a
   safe modern ceiling.

   Fields touched:
     IDC_MAXDOWN, IDC_MAXUP           — Connection page
     IDC_DOWNLOAD_CAP, IDC_UPLOAD_CAP — Statistics graph scale

2. **Slot Allocation spin cap raised from 100 to 100,000 kB/s.**

   Previously artificially pinned to 100 even though the underlying
   pref has always been uint32 (Preferences.h s_slotallocation /
   GetSlotAllocation). With MaxUpload now at 1,000,000, the per-slot
   reservation needs matching headroom. 100,000 = 1/10 of the new
   upload ceiling keeps the upload ratio sensible: below that the
   slot-count formula (MaxUpload / SlotAllocation) can still grow,
   above it MIN_UP_CLIENTS_ALLOWED=2 takes over and the knob stops
   being useful anyway.

   Field touched: IDC_SLOTALLOC (Connection page).

3. **Spin control widths: hardcoded wxSize(100,-1) fixed up so +/-
   buttons render without clipping on GTK 3 and other modern themes.**

   The hardcoded 100 px was too narrow for wxSpinCtrl to render both
   spin buttons when the value field holds 5+ digits; the + button
   ends up clipped on the Connection, Security and other prefs pages.

   - The three bandwidth fields on the Connection page (Download,
     Upload, Slot Allocation) use wxSize(140,-1) so they are visually
     aligned at the same width regardless of typed digit count.
   - The remaining 13 wider spin controls (ports, max sources, max
     connections, disk-space minimum, web-config ports, graph scales,
     MaxConnections5sec) switch to wxDefaultSize and let wx compute a
     width that fits the text + both buttons from theme metrics.
   - The few narrower fields (wxSize(40,-1), wxSize(45,-1),
     wxSize(60,-1) for single- or few-digit values like retry counts)
     are intentionally left alone.
mrjimenez pushed a commit that referenced this pull request Apr 23, 2026
Three small UI fixes on the Preferences dialog.

1. **Bandwidth spin caps raised from 19375 kB/s to 1,000,000 kB/s.**

   The bandwidth spin controls in src/muuli_wdr.cpp were capped at
   19375 kB/s (~155 Mbit/s), a floor from the pre-gigabit-Ethernet era.
   Users on gigabit or multi-gig links saw the value silently clamp
   when they typed anything higher. #436 has already widened MaxUpload /
   MaxDownload prefs to uint32, and the upload throttler's bytesToSpend
   arithmetic (sint32 accumulator ticking at ~1 kHz) still has ~2
   seconds of headroom before overflow at 1 GB/s, so 1,000,000 is a
   safe modern ceiling.

   Fields touched:
     IDC_MAXDOWN, IDC_MAXUP           — Connection page
     IDC_DOWNLOAD_CAP, IDC_UPLOAD_CAP — Statistics graph scale

2. **Slot Allocation spin cap raised from 100 to 100,000 kB/s.**

   Previously artificially pinned to 100 even though the underlying
   pref has always been uint32 (Preferences.h s_slotallocation /
   GetSlotAllocation). With MaxUpload now at 1,000,000, the per-slot
   reservation needs matching headroom. 100,000 = 1/10 of the new
   upload ceiling keeps the upload ratio sensible: below that the
   slot-count formula (MaxUpload / SlotAllocation) can still grow,
   above it MIN_UP_CLIENTS_ALLOWED=2 takes over and the knob stops
   being useful anyway.

   Field touched: IDC_SLOTALLOC (Connection page).

3. **Spin control widths: hardcoded wxSize(100,-1) fixed up so +/-
   buttons render without clipping on GTK 3 and other modern themes.**

   The hardcoded 100 px was too narrow for wxSpinCtrl to render both
   spin buttons when the value field holds 5+ digits; the + button
   ends up clipped on the Connection, Security and other prefs pages.

   - The three bandwidth fields on the Connection page (Download,
     Upload, Slot Allocation) use wxSize(140,-1) so they are visually
     aligned at the same width regardless of typed digit count.
   - The remaining 13 wider spin controls (ports, max sources, max
     connections, disk-space minimum, web-config ports, graph scales,
     MaxConnections5sec) switch to wxDefaultSize and let wx compute a
     width that fits the text + both buttons from theme metrics.
   - The few narrower fields (wxSize(40,-1), wxSize(45,-1),
     wxSize(60,-1) for single- or few-digit values like retry counts)
     are intentionally left alone.
@got3nks
got3nks deleted the pr/widen-speed-limits branch May 3, 2026 15:19
got3nks added a commit to got3nks/amule that referenced this pull request Jul 11, 2026
…tails (amule-project#418) (amule-project#436)

* feat(amuleapi): audio/video media metadata over EC + REST + File Details (amule-project#418)

Part 1 (amuled/EC): six new EC_TAG_KNOWNFILE_MEDIA_* tag codes
(0x0410-0x0415, added to ECCodes.h + .abstract + name switch), emitted in
the CEC_SharedFile_Tag base ctor from FT_MEDIA_* and guarded by
GetMetaDataVer() != 0 so non-media files add no tags. Both /shared and
/downloads (partfiles) carry them via the shared base ctor.

Part 2 (webapi): decode into a FileSnapshot media sub-struct (has_media
gate); emit an inline `media` object {length_s,bitrate,codec,artist,
album,title} on GET /downloads/{hash} and GET /shared/{hash}, omitted
entirely when the file has no probed metadata.

Part 3 (GUI): a new 'Media Info' box in the File Details dialog
(fileDetails() + IDC_FD_MEDIA_* ids), populated in
CFileDetailDialog::UpdateData() from FT_MEDIA_*; amulegui decodes the
Part-1 EC tags into the proxy file via AddTagUnique so the identical
GetIntTagValue/GetStrTagValue/GetMetaDataVer calls work in both builds.
Layout + styling mirror the ICH box. Reuses existing translatable strings
(Length:/Bitrate:/Codec:/Artist:/Album:/Title:/Media Info/N/A) — no new
strings, no catalog regen.

RefresherTest gains a media decode case; curl 04 asserts media is omitted
for unprobed files; REST reference documents the media object.

* i18n: regenerate app catalogs for the Media Info box strings (amule-project#418)

New translatable strings from the File Details Media Info box: "Media
Info", "Length :", "Bitrate :", "Codec :", "Artist :", "Album :"
("Title :" already existed). App catalog only (scripts/update-po.sh);
manpage/po4a catalogs untouched.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants