HTTPDownload: bound libcurl connect-phase via GetNativeHandle() - #565
Merged
mrjimenez merged 1 commit intoMay 11, 2026
Merged
Conversation
CHTTPDownloadThread sets CURLOPT_NOSIGNAL=1 and CURLOPT_CONNECTTIMEOUT_MS=30000 on the underlying CURL* (via wxWebRequest::GetNativeHandle, public wx API since 3.2.0) immediately after CreateRequest, before Start(). Bounds the UI/EC freeze when wxWebRequest's libcurl backend (Linux/*BSD only) tries to reach an unreachable HTTPS endpoint (captive portal, blocked TCP route, non-routable IP) — the connect phase now gives up after 30 s instead of waiting the kernel's full TCP-SYN retry sequence (~2 min) or libcurl's default 300 s timeout. Does not close libcurl's threaded-resolver pthread_join hang in curl_easy_cleanup() (that needs either libcurl built with --enable-ares or a real DNS timeout under 30 s); bounds the visible window for the common-case unreachable-endpoint scenario. Mac (NSURLSession backend) and Windows (WinHTTP backend) are unaffected by both the bug and this fix; #if wxUSE_WEBREQUEST_CURL gates the new code so non-curl backends compile unchanged. find_package(CURL) is soft-required on Linux/*BSD; if libcurl-dev is absent the patch silently no-ops and a configure-time STATUS line tells the developer how to enable it.
got3nks
force-pushed
the
feature/httpdownload-curlopt-tuning
branch
from
May 10, 2026 10:20
e029c9b to
a83824a
Compare
got3nks
added a commit
to got3nks/amule
that referenced
this pull request
Jul 23, 2026
…mule-project#565) Fix the CMake wiring so mmap is actually reachable (amule-project#34): the port never set HAVE_MMAP (glib21.cmake probed munmap, not mmap) and never passed ENABLE_MMAP to the compiler, so USE_MMAP was dead on every CMake build even with -DENABLE_MMAP=YES. Add the missing mmap/sigaction probes and a single MMAP_SUPPORTED capability macro (set when mmap/munmap/sysconf/_SC_PAGESIZE/ sigaction are all present) gating the code path, the preferences checkbox and the EC tag. ENABLE_MMAP becomes a default-ON build opt-out (no external dependency; all libc). Make mmap use a runtime preference (MMapEnabled, default OFF): - CFileArea reads an atomic flag at ReadAt/StartWriteAt; the per-area mode is captured in m_mmap_buffer so FlushAt/Close stay state-driven -- safe to flip live with active downloads and uploads (in-flight blocks finish in their original mode). - The SIGSEGV/SIGBUS recovery handler installs once, when mmap is first enabled, rather than per read/write and never when off, so it cannot collide with sanitizers/debuggers/crash reporters. - Advanced-tab checkbox; capability negotiated over EC (EC_TAG_FILES_MMAP_ SUPPORTED/_ENABLED) so amulegui/amulecmd/amuleweb/amuleapi show the toggle only when the connected daemon supports mmap (tag-presence == capability; works cross-platform, e.g. Windows GUI to a Linux daemon). Relax the 4 GiB per-area cap (forum 16444): it only guards a 32-bit off_t. On 64-bit off_t -- every modern LFS build, including 32-bit-with-LFS (aMule inherits _FILE_OFFSET_BITS=64 from wx) -- mmap handles large offsets natively, verified against a >4 GiB region, so large files get mmap for their whole length; the cap remains only for a (wx-precluded) non-LFS 32-bit build.
got3nks
added a commit
to got3nks/amule
that referenced
this pull request
Jul 23, 2026
…-project#566) Follow-up to amule-project#565: surface the memory-mapped file I/O preference on the REST API. files.mmap_supported is a read-only daemon capability (mirrors upnp_available), read from the EC_TAG_FILES_MMAP_SUPPORTED tag; files.mmap_enabled is the runtime value. A PATCH that sets mmap_enabled is rejected with 409 when the connected daemon lacks mmap support, so the option is only writable against a core that can actually use it. Updates docs/api/REFERENCE.md and the 15-preferences-patch curl smoke (round-trip on a mmap-capable daemon; the 409 capability gate otherwise).
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
CHTTPDownloadThreadsetsCURLOPT_NOSIGNAL=1andCURLOPT_CONNECTTIMEOUT_MS=30000on the underlyingCURL*(viawxWebRequest::GetNativeHandle(), public wx API since 3.2.0) immediately afterCreateRequest, beforeStart(). Bounds the UI/EC freeze when wxWebRequest's libcurl backend (Linux/*BSD only) tries to reach an unreachable HTTPS endpoint — the connect phase now gives up after 30 s instead of waiting the kernel's full TCP-SYN retry sequence (~2 min) or libcurl's default 300 s timeout.Fix
Three small pieces, all gated by
#if wxUSE_WEBREQUEST_CURLso non-curl backends compile unchanged:src/HTTPDownload.cpp— afterCreateRequest, fetch the nativeCURL*andcurl_easy_setoptthe two options.cmake/wx.cmake— softfind_package(CURL)on Linux/*BSD; if libcurl headers are absent the patch silently no-ops and a configure-timeSTATUSline tells the developer how to enable it.src/CMakeLists.txt— singleforeachadds the CURL include + link to whichever ofamule/amuled/amuleguiexist in the configured build.Caveats
Does not close libcurl's threaded-resolver
pthread_joinhang incurl_easy_cleanup()— that requires either libcurl built with--enable-ares(out of our control on Ubuntu's default libcurl) or a real DNS timeout under 30 s. This patch bounds the visible window for the common-case unreachable-endpoint scenario.macOS (NSURLSession backend) and Windows (WinHTTP backend) are unaffected by both the bug and this fix.