DestroyAllSessions destroys every active session without holding the manager lock while running per-session cleanup.
()
| 729 | // naturally before invoking DestroyAllSessions for final teardown. |
| 730 | func (sm *SessionManager) BeginDrain() { |
| 731 | sm.lifecycle.close() |
| 732 | sm.mu.Lock() |
| 733 | sm.failWaitersLocked(ErrSessionManagerDraining) |
| 734 | sm.mu.Unlock() |
| 735 | } |
| 736 | |
| 737 | // DestroyAllSessions destroys every active session without holding the manager |
| 738 | // lock while running per-session cleanup. |
| 739 | func (sm *SessionManager) DestroyAllSessions() { |
| 740 | for { |
| 741 | sm.BeginDrain() |
| 742 | sm.mu.Lock() |
| 743 | pids := sm.sessionPIDsLocked() |
| 744 | sm.mu.Unlock() |
| 745 | if len(pids) == 0 { |
| 746 | sm.lifecycle.closeAndWait() |
| 747 | return |
| 748 | } |
| 749 | for _, pid := range pids { |