Skip to content

amulegui: clean startup on Cancel + watchdog on wrong connection data - #465

Merged
mrjimenez merged 1 commit into
amule-project:masterfrom
got3nks:amulegui-startup-fixes
Apr 23, 2026
Merged

amulegui: clean startup on Cancel + watchdog on wrong connection data#465
mrjimenez merged 1 commit into
amule-project:masterfrom
got3nks:amulegui-startup-fixes

Conversation

@got3nks

@got3nks got3nks commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Two small fixes in src/amule-remote-gui.cpp that both address problems the user hits on the very first screen of amulegui — the EC connection dialog.

  1. Cancel leaves threads running. Clicking Cancel on the initial connection dialog printed 4 threads were not terminated by the application on exit. OnInit() returned false without 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 called ShutDown() / OnExit().

  2. Wrong host / unreachable daemon hangs the app. Entering an incorrect host or a host where amuled isn'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 stop m_AsioService, destroy the CRemoteConnect socket, and delete poll_timer. Mirror of what ShutDown() does — necessary because OnInit() returning false skips the main loop entirely, so wx never runs its normal teardown.

Fix 2 — watchdog on the EC connect

amulegui constructs CRemoteConnect with this as the wxEvtHandler* notifier, which selects the async flavour of the connect: ConnectToCore() returns true as soon as the underlying connect() has been dispatched, and OnECConnection is delivered later via AddPendingEvent() 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 after ShowConnectionDialog() returns true. If it fires before OnECConnection:

  • a wxMessageBox explains 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 in ShutDown().

Files touched

 src/amule-remote-gui.cpp      | 58 ++++++++++++++++++++++++++++++-
 src/amule-remote-gui.h        |  7 ++++
 src/include/common/EventIDs.h |  3 +-

EventIDs.h only adds the new ID_REMOTE_CONNECT_TIMEOUT_TIMER enum 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 in OnECConnection before the 15 s elapses.

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.
@mrjimenez
mrjimenez merged commit 7856a39 into amule-project:master Apr 23, 2026
5 checks passed
@got3nks
got3nks deleted the amulegui-startup-fixes branch May 3, 2026 15:19
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.
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.

2 participants