Remove muxConnectionManager and replace with MuxManager#149
Merged
temporal-nick merged 25 commits intomainfrom Sep 15, 2025
Merged
Remove muxConnectionManager and replace with MuxManager#149temporal-nick merged 25 commits intomainfrom
temporal-nick merged 25 commits intomainfrom
Conversation
pglass
reviewed
Sep 9, 2025
pglass
approved these changes
Sep 15, 2025
| // TryConnectionOrElse grabs whatever connection is available and runs f on that connection. | ||
| // The received SessionWithConn is guaranteed to be nil, a valid yamux session, or a closed yamux session | ||
| func TryConnectionOrElse[T any](m *MuxManager, f func(*SessionWithConn) T, other T) T { | ||
| func (m *muxManager) TryConnectionOrElse(f func(*SessionWithConn) any, orElse any) any { |
Contributor
There was a problem hiding this comment.
nit: What do you think about calling this WithConnectionOrElse?
Collaborator
Author
There was a problem hiding this comment.
I could go either way on this. Usually Try is the thing that tells you the method won't block, but I agree that OrElse does basically the same job in this case
| // NewConnection waits on the TCP server for a connection, then provides it | ||
| func (r *receivingConnProvider) NewConnection() (net.Conn, error) { | ||
| conn, err := r.listener.Accept() | ||
| if r.shouldShutDown() { |
Contributor
There was a problem hiding this comment.
Do we need this, since we have the goroutine waiting on shouldShutdown already?
go func() {
<-shouldShutDown.Channel()
err := listener.Close()
if err != nil {
logger.Fatal("listener.Close failed", tag.Error(err))
}
connPv.hasCleanedUp.Shutdown()
}()I guess we could Accept() and then another goroutine could toggle shouldShouldDown to at L80. But if that's a concern, it could be toggled true at L89, also.
Collaborator
Author
There was a problem hiding this comment.
The listener would be cancelled regardless. This just customizes the error message
| } | ||
| func (tm *TransportManager) IsMuxActive(name string) bool { | ||
| return tm.muxConnManagers[name].status.Load() == int32(statusStarted) | ||
| //return tm.muxConnManagers[name].Load() == int32(statusStarted) |
Co-authored-by: Paul Glass <pnglass@gmail.com>
hai719
pushed a commit
to hai719/s2s-proxy
that referenced
this pull request
Nov 24, 2025
* Remove muxConnectionManager and replace with MuxManager * Fix unit tests, improve muxManager lifecycle * Fix shutdownch fake in mux_manager_test * Add missing channels to test * Clean up signaling logic, remove generics * Remove redundant IsShutdown check * Add metrics and logging for muxmanager * Ensure metricLabels is set, metrics are configured * Fix mux_manager_test * Refine connection metrics * have mux observer ping the session to get latency stats * Add more metrics * More metrics, wrap yamux logger * Move waiting for client metric close to include error case * Change to 30s stream timeout * Enable server log debugging * more logs * more logs * Include details about the replacement connection * Ensure grpc server restarts on error * fmt * Update metrics/prometheus_defs.go Co-authored-by: Paul Glass <pnglass@gmail.com> * Requested PR fixes * fmt --------- Co-authored-by: Paul Glass <pnglass@gmail.com>
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.
What was changed
Why?
Replacing the muxConnectionManager will remove its current locking bugs and replace it with this better-behaved pattern.
In adapting the existing unit tests, several bugs were found and fixed, and the observability has been improved.