Fix race conditions and improve lifecycle safety (#150) #152
Reference in New Issue
Block a user
Delete Branch "staging"
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 code quality improvements in the lifecycle module and related test files.
Changes
Race Condition Fixes
SetChannel()andChannel()by adding mutex protectionStartedAt()by adding mutex protectiontransportandinteractionpackages where variables were shared between goroutinesConcurrency Safety Improvements
Close()to release mutex before calling external code, preventing potential deadlocksSetChannel()reject calls afterClose()to prevent setting channel on torn-down lifecycleSetStatus()ignore calls afterClose()to ensure CLOSED is a terminal stateSetChannel()to prevent masking upstream bugsCode Quality Improvements
Close()to extract helper methods:closeChannel(),closeConnection(),cleanupRegistry(),cleanupForwarder()isClosedError()to remove redundant string comparisonPortRegistryinterface for better interface segregation (removed dependency on fullport.Port)cleanupRegistry()conditional on non-empty slug to avoid unnecessary registry callsstartedAtto be set when session starts running instead of at object creationReviewed-on: #150
Co-authored-by: Bagas bagas@fossy.my.id
Co-committed-by: Bagas bagas@fossy.my.id