Close ensures that the server is no longer accepting new connections and closes all existing connections. Existing connections will receive [io.EOF]. The error value is that of the underlying [net.Listener.Close] call.
()
| 95 | // |
| 96 | // The error value is that of the underlying [net.Listener.Close] call. |
| 97 | func (pl *PluginServer) Close() error { |
| 98 | if pl == nil { |
| 99 | return nil |
| 100 | } |
| 101 | logrus.Trace("Closing plugin server") |
| 102 | // Close connections first to ensure the connections get io.EOF instead |
| 103 | // of a connection reset. |
| 104 | pl.closeAllConns() |
| 105 | |
| 106 | // Try to ensure that any active connections have a chance to receive |
| 107 | // io.EOF. |
| 108 | runtime.Gosched() |
| 109 | |
| 110 | return pl.l.Close() |
| 111 | } |
| 112 | |
| 113 | func (pl *PluginServer) closeAllConns() { |
| 114 | pl.mu.Lock() |