From 3cb3cdb8ddf52f41386b70dff19591d4d0de28f7 Mon Sep 17 00:00:00 2001 From: Dingjun Date: Sat, 22 Apr 2017 11:33:26 +0800 Subject: [PATCH] change log output --- http2_proxy.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/http2_proxy.go b/http2_proxy.go index 86f5383..d77f3d6 100644 --- a/http2_proxy.go +++ b/http2_proxy.go @@ -88,7 +88,7 @@ func (h *handler) handleConnect(w http.ResponseWriter, r *http.Request) { resp, err := h.transport.RoundTrip(r) if err != nil { - log.Println(err) + log.Printf("roundtrip: %s", err) w.WriteHeader(http.StatusServiceUnavailable) fmt.Fprintf(w, "%s", err) return @@ -108,6 +108,7 @@ func (h *handler) handleConnect(w http.ResponseWriter, r *http.Request) { c, _, err := w.(http.Hijacker).Hijack() if err != nil { + log.Println("hijack: %s", err) w.WriteHeader(http.StatusServiceUnavailable) fmt.Fprintf(w, "%s", err) return @@ -171,7 +172,7 @@ func (p *clientConn) GetClientConn(req *http.Request, addr string) (*http2.Clien p.lock.Lock() defer p.lock.Unlock() - if p.conn != nil { + if p.conn != nil && p.conn.CanTakeNewRequest() { return p.conn, nil } @@ -211,14 +212,14 @@ func (p *clientConn) GetClientConn(req *http.Request, addr string) (*http2.Clien } func (p *clientConn) MarkDead(conn *http2.ClientConn) { - p.lock.Lock() - defer p.lock.Unlock() + //p.lock.Lock() + //defer p.lock.Unlock() if debug { log.Println("mark dead") } - p.conn = nil + //p.conn = nil } var debug bool