Fix LAN network cleanup state for stability#959
Conversation
@check-spelling-bot Report🔴 Please reviewSee the 📂 files view, the 📜action log, or 📝 job summary for details.Unrecognized words (27)These words are not needed and should be removedBlabla bmf NMove NOCOLOR SId SubtagsTo accept these unrecognized words as correct and remove the previously acknowledged and now absent words, you could run the following commands... in a clone of the git@github.com:calcitem/Sanmill.git repository curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/main/apply.pl' |
perl - 'https://github.com/calcitem/Sanmill/actions/runs/18441878547/attempts/1' &&
git commit -m 'Update check-spelling metadata'OR To have the bot accept them for you, comment in the PR quoting the following line: Forbidden patterns 🙅 (2)In order to address this, you could change the content to not match the forbidden patterns (comments before forbidden patterns may help explain why they're forbidden), add patterns for acceptable instances, or adjust the forbidden patterns themselves. These forbidden patterns matched content: s.b. intoPatternErrors and Warnings ❌ (2)See the 📂 files view, the 📜action log, or 📝 job summary for details.
See ❌ Event descriptions for more information. If the flagged items are 🤯 false positivesIf items relate to a ...
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting
|
|
||
| _messageQueue.clear(); | ||
| _isProcessingMessages = false; | ||
| if (_protocolHandshakeCompleter != null && | ||
| !_protocolHandshakeCompleter!.isCompleted) { | ||
| _protocolHandshakeCompleter!.complete(false); | ||
| } | ||
| _protocolHandshakeCompleter = null; | ||
| _heartbeatStarted = false; | ||
| _isReconnecting = false; | ||
| _messagesSent = 0; | ||
| _messagesReceived = 0; | ||
| _reconnectAttempts = 0; | ||
| _opponentAddress = null; | ||
| _opponentPort = null; | ||
| _lastConnectionTime = null; | ||
|
|
||
| logger.i("$_logTag Network disposed"); | ||
| if (!markDisposed) { | ||
| _disposed = false; | ||
| logger.i("$_logTag Network connection reset"); |
There was a problem hiding this comment.
Guard
_disposeInternals against re-entrancy
The new _disposeInternals({bool markDisposed = true}) skips setting _disposed when markDisposed is false and immediately resets it to false at the end. _handleDisconnection now calls this method with markDisposed: false, so during teardown the service never enters a disposed state. Socket listeners (onError, onDone) and heartbeat timers check _disposed before invoking _handleDisconnection, meaning multiple callbacks that fire during the same disconnect will all pass the check and re-enter the teardown logic. This can invoke onDisconnected and UI updates multiple times and race concurrent clean‑ups. To keep the service reusable while still preventing repeated work, _disposeInternals should temporarily mark _disposed true while cleaning up and only set it back to false after the reset completes.
Useful? React with 👍 / 👎.
Summary
Testing
dartis unavailable)https://chatgpt.com/codex/tasks/task_e_68eb6e4e99288320a2c3959ef52108af