Auto-rebuild listener on fatal socket errors and refactor listener creation#44
Auto-rebuild listener on fatal socket errors and refactor listener creation#44CypherPotato wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0e5d53d365
ℹ️ 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 "@codex address that feedback".
| catch (SocketException) { | ||
| } |
There was a problem hiding this comment.
Dispose failed rebuilt listener before retry loop
When CreateListenerSocket()/Bind/Listen throws during RebuildListenerAsync, the catch (SocketException) block swallows the exception and immediately retries without disposing the just-created newListener. In a persistent failure (e.g., endpoint temporarily unavailable), this leaks one socket handle every 250ms, which can exhaust file descriptors and prevent the host from recovering.
Useful? React with 👍 / 👎.
Motivation
Description
_listenerwith a mutable socket and introduceCreateListenerSocket()to centralize socket construction and options previously inConfigureListenerSocket().Start()dispose the previous listener (if any) and recreate a fresh listener, then bind and listen before starting the accept pool._listenerRestartingflag and logic inStartAccept(),OnAcceptCompleted()andProcessAcceptInline()to detect fatalSocketErrorvalues viaIsListenerFatalError()and triggerRebuildListenerAsync()which retries creating/binding a new listener and restarts accept loops.ProcessAcceptInline()to indicate caller should stop rearming and handle restart scenarios, and adjust accept-queueing logic accordingly.Testing
Codex Task