closeConnections immediately closes all hijacked connections (both to client and backend).
()
| 401 | |
| 402 | // closeConnections immediately closes all hijacked connections (both to client and backend). |
| 403 | func (h *Handler) closeConnections() error { |
| 404 | var err error |
| 405 | h.connectionsMu.Lock() |
| 406 | defer h.connectionsMu.Unlock() |
| 407 | |
| 408 | for _, oc := range h.connections { |
| 409 | if oc.gracefulClose != nil { |
| 410 | // this is potentially blocking while we have the lock on the connections |
| 411 | // map, but that should be OK since the server has in theory shut down |
| 412 | // and we are no longer using the connections map |
| 413 | gracefulErr := oc.gracefulClose() |
| 414 | if gracefulErr != nil && err == nil { |
| 415 | err = gracefulErr |
| 416 | } |
| 417 | } |
| 418 | closeErr := oc.conn.Close() |
| 419 | if closeErr != nil && err == nil { |
| 420 | err = closeErr |
| 421 | } |
| 422 | } |
| 423 | return err |
| 424 | } |
| 425 | |
| 426 | // cleanupConnections closes hijacked connections. |
| 427 | // Depending on the value of StreamCloseDelay it does that either immediately |
no test coverage detected