drainInflight waits for all in-flight operations to complete. It acquires inflightMu to prevent processOnce from spawning new goroutines (via inflight.Add) concurrently with Wait, which would violate sync.WaitGroup's contract. https://pkg.go.dev/sync#WaitGroup.Add > Note that calls with a positive
()
| 9885 | // https://pkg.go.dev/sync#WaitGroup.Add |
| 9886 | // > Note that calls with a positive delta that occur when the counter is zero must happen before a Wait. |
| 9887 | func (p *Server) drainInflight() { |
| 9888 | p.inflightMu.Lock() |
| 9889 | p.inflight.Wait() |
| 9890 | p.inflightMu.Unlock() |
| 9891 | } |
| 9892 | |
| 9893 | // refreshExpiredMCPTokens checks each MCP OAuth2 token and refreshes |
| 9894 | // any that are expired (or about to expire). Tokens without a |