(ctx *RequestCtx, r io.Reader, c net.Conn, s *Server, h HijackHandler)
| 2761 | } |
| 2762 | |
| 2763 | func hijackConnHandler(ctx *RequestCtx, r io.Reader, c net.Conn, s *Server, h HijackHandler) { |
| 2764 | hjc := s.acquireHijackConn(r, c) |
| 2765 | h(hjc) |
| 2766 | |
| 2767 | // When the caller keeps using the hijacked connection after return, |
| 2768 | // the buffered reader must remain owned by that escaped connection. |
| 2769 | if br, ok := r.(*bufio.Reader); ok && !s.KeepHijackedConns { |
| 2770 | releaseReader(s, br) |
| 2771 | } |
| 2772 | if !s.KeepHijackedConns { |
| 2773 | c.Close() |
| 2774 | s.releaseHijackConn(hjc) |
| 2775 | } |
| 2776 | s.releaseCtx(ctx) |
| 2777 | } |
| 2778 | |
| 2779 | func (s *Server) acquireHijackConn(r io.Reader, c net.Conn) *hijackConn { |
| 2780 | v := s.hijackConnPool.Get() |
searching dependent graphs…