amulegui: clean startup on Cancel + watchdog on wrong connection data - #465
Merged
Merged
Conversation
Two related startup bugs in amulegui: 1. Clicking Cancel on the initial connection dialog left the app reporting "4 threads were not terminated by the application" on exit. OnInit() returned false without tearing down the Asio service, the core poll timer or the remote-connect socket it had already created, and because the main loop never ran, wx never called ShutDown() / OnExit(). Unwind those explicitly on the cancel path. 2. Entering a wrong host / unreachable daemon and clicking OK left the app "not responding" (per the OS) for several minutes while the TCP SYN silently timed out. The main loop was running but no window had been shown yet, so the user had no visible signal. Add a 15s watchdog timer started right after ShowConnectionDialog() returns true; if no EC connection event has arrived by then, show an error dialog and exit cleanly. The timer is cancelled in OnECConnection (success or failure) and in ShutDown as a safety net.
ngosang
pushed a commit
to ngosang/amule
that referenced
this pull request
Jul 13, 2026
amule-project#444) (amule-project#465) Follow-up to amule-project#452, from two issues reported after a successful reconnect. 1. Empty download queue + shared file lists (restart required) The EC request FIFO (CRemoteConnect::m_req_fifo) assumes the core answers every request in FCFS order. A socket dropped mid-poll leaves the requests that were on the air unanswered, so their handlers linger in the FIFO. After the reconnect each reply pops the wrong (stale) handler: a stats reply routed to CKnownFilesRem drives its one-shot post-reconnect reconcile against an empty file set, and the absence-prune wipes the whole library. It is intermittent (depends how many requests were in flight at the drop) and only a full restart clears it, since a fresh process starts with an empty FIFO. - CRemoteConnect::DiscardRequestQueue() flushes the FIFO and zeroes the in-flight counter on reconnect, rewinding each orphaned handler's request state (CECPacketHandlerBase::AbortPendingRequest, overridden by CRemoteContainer to reset its request SM to IDLE) so a container whose reply died still re-requests instead of wedging. - Defensive guard in CKnownFilesRem::ProcessUpdate: if the first post-reconnect reply carries no files while the list is still populated, skip the absence-prune and keep the one-shot armed for the next poll. 2. Ellipsis mojibake on Windows The reconnect status strings embedded a literal U+2026. On the untranslated (English) path the narrow msgid is decoded with the C locale (CP1252 on Windows), rendering as garbage in both the dialog and the log. Replaced the ellipsis with "..." in every source msgid, and -- to keep existing translations valid -- in every catalog msgid/msgstr as well (regen leaves no new fuzzy entries). Client-side only: no daemon or EC wire-protocol change, so the updated aMuleGUI works against a stock amuled.
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
Two small fixes in
src/amule-remote-gui.cppthat both address problems the user hits on the very first screen ofamulegui— the EC connection dialog.Cancel leaves threads running. Clicking Cancel on the initial connection dialog printed
4 threads were not terminated by the applicationon exit.OnInit()returnedfalsewithout tearing down the Asio service, the core poll timer and the remote-connect socket it had already created, and because the main loop never ran, wx never calledShutDown()/OnExit().Wrong host / unreachable daemon hangs the app. Entering an incorrect host or a host where
amuledisn't listening, then clicking OK, left amulegui in the "not responding" state (the OS offers to force-close it) for several minutes while the TCP SYN silently timed out. The main loop was running, but no window had yet been shown, so the user had no visible signal that anything was happening.3 files changed, 67 insertions(+), 1 deletion(-). No behaviour change for the happy path.
Fix 1 — unwind partial init on Cancel
On the cancel path out of
ShowConnectionDialog(), explicitly stopm_AsioService, destroy theCRemoteConnectsocket, and deletepoll_timer. Mirror of whatShutDown()does — necessary becauseOnInit()returningfalseskips the main loop entirely, so wx never runs its normal teardown.Fix 2 — watchdog on the EC connect
amulegui constructs
CRemoteConnectwiththisas thewxEvtHandler*notifier, which selects the async flavour of the connect:ConnectToCore()returnstrueas soon as the underlyingconnect()has been dispatched, andOnECConnectionis delivered later viaAddPendingEvent()once the socket resolves one way or the other. For an unreachable host, the socket layer keeps retrying the SYN for minutes before giving up, during which the user sees a frozen app with no visible window.A 15 s one-shot
wxTimer(ID_REMOTE_CONNECT_TIMEOUT_TIMER) is started right afterShowConnectionDialog()returnstrue. If it fires beforeOnECConnection:wxMessageBoxexplains the timeout and names the host:port the user typed;ShutDown()tears everything down;ExitMainLoop()returns control to wx.The watchdog is cancelled at the top of
OnECConnection(success and failure paths), and also as a safety net inShutDown().Files touched
EventIDs.honly adds the newID_REMOTE_CONNECT_TIMEOUT_TIMERenum value at the end of the existing timer-event block.Risk
Scoped strictly to
amulegui. The core (amule/amuled) is not touched. Happy-path connects are unaffected: on success the watchdog fires its own cancel inOnECConnectionbefore the 15 s elapses.