fix(session): resolve race conditions #151
Reference in New Issue
Block a user
Delete Branch "fix/session-race-conditions"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Comprehensive fixes for race conditions, concurrency bugs, and a critical session handling bug across the session package and its child packages.
Changes
Bug Fix: waitForTCPIPForward fails on non-tcpip-forward global requests
waitForTCPIPForward()from a single select to a for loop that drains non-tcpip-forward requests gracefullyRace Condition Fixes
SetType(),SetForwardedPort(),SetListener()) by addingLock()/Unlock()protectionTunnelType(),ForwardedPort(),Listener()) by addingRLock()/RUnlock()protectionslug.Set()by addingLock()/Unlock()protectionslug.String()by addingRLock()/RUnlock()protectionConcurrency Safety Improvements
OpenForwardedChannel()to usef.ForwardedPort()getter instead of direct field accessClose()in forwarder to usef.Listener()getter consistently instead of accessingf.listenerdirectlyHandleTCPForward()where the goroutine runningtcpServer.Serve(listener)wrote to the outer err variable from the enclosing function scopetcpServer.Serve(listener)toif err := tcpServer.Serve(listener)so the goroutine uses a local variable