()
| 149 | } |
| 150 | |
| 151 | func (c *Conn) close() error { |
| 152 | c.closeMu.Lock() |
| 153 | defer c.closeMu.Unlock() |
| 154 | |
| 155 | if c.isClosed() { |
| 156 | return net.ErrClosed |
| 157 | } |
| 158 | runtime.SetFinalizer(c, nil) |
| 159 | close(c.closed) |
| 160 | |
| 161 | // Have to close after c.closed is closed to ensure any goroutine that wakes up |
| 162 | // from the connection being closed also sees that c.closed is closed and returns |
| 163 | // closeErr. |
| 164 | err := c.rwc.Close() |
| 165 | // With the close of rwc, these become safe to close. |
| 166 | c.msgWriter.close() |
| 167 | c.msgReader.close() |
| 168 | return err |
| 169 | } |
| 170 | |
| 171 | func (c *Conn) setupWriteTimeout(ctx context.Context) bool { |
| 172 | if ctx.Done() == nil { |
no test coverage detected