WaitAll returns a channel that is closed when all children have exited. Caller should call this after SignalAll to wait for graceful shutdown. NOTE: This method creates a new goroutine each time it's called. It captures a snapshot of current children at call time - children added after the call won
()
| 106 | // a snapshot of current children at call time - children added after the call |
| 107 | // won't be waited on. For typical shutdown scenarios, call this once after SignalAll. |
| 108 | func (ct *ChildTracker) WaitAll() <-chan struct{} { |
| 109 | done := make(chan struct{}) |
| 110 | |
| 111 | go func() { |
| 112 | ct.mu.RLock() |
| 113 | children := make([]*ChildProcess, 0, len(ct.children)) |
| 114 | for _, child := range ct.children { |
| 115 | children = append(children, child) |
| 116 | } |
| 117 | ct.mu.RUnlock() |
| 118 | |
| 119 | for _, child := range children { |
| 120 | <-child.done // Wait for each child to exit |
| 121 | } |
| 122 | close(done) |
| 123 | }() |
| 124 | |
| 125 | return done |
| 126 | } |
| 127 | |
| 128 | // spawnChildForTLS spawns a child worker process to handle TLS handshake and the rest of the connection. |
| 129 | // This is called after the parent has received an SSL request and sent 'S'. |
no outgoing calls