Skip to content

Commit

Permalink
cmd/tsdbrelay: Drain relay response so that connection is eligible fo…
Browse files Browse the repository at this point in the history
…r reuse.
  • Loading branch information
Jason Harvey committed Mar 13, 2017
1 parent 207a064 commit bd27073
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd/tsdbrelay/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"flag"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/http/httptest"
"net/http/httputil"
Expand Down Expand Up @@ -249,6 +250,8 @@ func (rp *relayProxy) relayPut(responseWriter http.ResponseWriter, r *http.Reque
verbose("bosun relay error: %v", err)
return
}
// Drain up to 512 bytes and close the body to let the Transport reuse the connection
io.CopyN(ioutil.Discard, resp.Body, 512)
resp.Body.Close()
verbose("bosun relay success")
}()
Expand Down Expand Up @@ -283,6 +286,8 @@ func (rp *relayProxy) relayPut(responseWriter http.ResponseWriter, r *http.Reque
collect.Add("additional.puts.error", tags, 1)
continue
}
// Drain up to 512 bytes and close the body to let the Transport reuse the connection
io.CopyN(ioutil.Discard, resp.Body, 512)
resp.Body.Close()
verbose("secondary relay success")
collect.Add("additional.puts.relayed", tags, 1)
Expand Down Expand Up @@ -383,6 +388,8 @@ func (rp *relayProxy) relayMetadata(responseWriter http.ResponseWriter, r *http.
verbose("secondary relay metadata error: %v", err)
continue
}
// Drain up to 512 bytes and close the body to let the Transport reuse the connection
io.CopyN(ioutil.Discard, resp.Body, 512)
resp.Body.Close()
verbose("secondary relay metadata success")
}
Expand Down

0 comments on commit bd27073

Please sign in to comment.