Close stops the server. It must not be called before or concurrently with Start.
()
| 600 | // |
| 601 | // It must not be called before or concurrently with Start. |
| 602 | func (s *Server) Close() error { |
| 603 | didClose := false |
| 604 | s.closeOnce.Do(func() { |
| 605 | didClose = true |
| 606 | s.close() |
| 607 | }) |
| 608 | if !didClose { |
| 609 | return fmt.Errorf("tsnet: %w", net.ErrClosed) |
| 610 | } |
| 611 | return nil |
| 612 | } |
| 613 | |
| 614 | func (s *Server) close() { |
| 615 | // Close listeners under s.mu, then release before the heavy shutdown |