Skip to content

Background refresh completion can wedge when UI PostMessage fails

Summary

GeoLocation and IPFilter background refresh workers clear their in-progress flags only when a UI completion message is delivered. Worker cleanup ignores PostMessage failure, so a destroyed window, full message queue, or other post failure can leave refresh state permanently stuck.

This blocks Beta 0.7.3 because the current fix for stuck refresh flags does not cover lost completion delivery.

Evidence

  • srchybrid/GeoLocation.cpp:763 sets m_bBackgroundRefreshQueued before starting the worker.
  • srchybrid/GeoLocation.cpp:782 clears the flag only in the UI completion handler.
  • srchybrid/GeoLocation.cpp:1022 discards the PostMessage result.
  • srchybrid/IPFilterUpdater.cpp:367 sets m_bBackgroundRefreshQueued before starting the worker.
  • srchybrid/IPFilterUpdater.cpp:384 clears the flag only in the UI completion handler.
  • srchybrid/IPFilterUpdater.cpp:424 discards the PostMessage result.

Execution Plan

  1. Revalidate refresh object lifetime during normal runtime and application shutdown.
  2. Decide whether failed completion posts should synchronously clear state, enqueue a fallback, or transition to a terminal shutdown state.
  3. Make completion delivery explicit: successful UI post means UI owns final state transition; failed post means worker or owner records terminal cleanup.
  4. Check ResumeThread failure and ensure a never-started worker cannot leave refresh queued.
  5. Add focused seams for failed PostMessage, destroyed notify window, and ResumeThread failure.
  6. Verify manual and automatic refresh still serialize correctly.

Acceptance Criteria

  • GeoLocation refresh cannot remain queued solely because completion posting failed.
  • IPFilter refresh cannot remain queued solely because completion posting failed.
  • Shutdown behavior is deterministic and does not post to invalid windows.
  • Existing successful refresh behavior is unchanged.

Validation

  • 2026-05-08: Done in app commit 1a09692.
  • python -m emule_workspace build app --workspace-root . --config Release --platform x64 --variant main passed; log root workspaces\v0.72a\state\build-logs\20260508-095344.
  • python -m emule_workspace build tests --workspace-root . --config Release --platform x64 --test-run-variant main passed; log root workspaces\v0.72a\state\build-logs\20260508-095409.
  • python -m emule_workspace validate --workspace-root . passed.
  • Focused doctest passed: repos\emulebb-build-tests\build\eMulebb-workspace-v0.72a-eMule-main\x64\Release\emule-tests.exe --test-suite=parity --test-case="IP-filter update seam detects due automatic refreshes".
  • Code validation: GeoLocation and IPFilter refresh queued state is now interlocked, failed UI posts fall back to synchronous delivery when the window is valid, and unavailable windows clear the queued flag instead of wedging the refresh state.