| 228 | } |
| 229 | |
| 230 | func (c *Conn) waitGoroutines() error { |
| 231 | t := time.NewTimer(time.Second * 15) |
| 232 | defer t.Stop() |
| 233 | |
| 234 | c.closeReadMu.Lock() |
| 235 | closeRead := c.closeReadCtx != nil |
| 236 | c.closeReadMu.Unlock() |
| 237 | if closeRead { |
| 238 | select { |
| 239 | case <-c.closeReadDone: |
| 240 | case <-t.C: |
| 241 | return errors.New("failed to wait for close read goroutine to exit") |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | select { |
| 246 | case <-c.closed: |
| 247 | case <-t.C: |
| 248 | return errors.New("failed to wait for connection to be closed") |
| 249 | } |
| 250 | |
| 251 | return nil |
| 252 | } |
| 253 | |
| 254 | func parseClosePayload(p []byte) (CloseError, error) { |
| 255 | if len(p) == 0 { |