From 080c11d14ee18792cefdb46f575a3270358f46e9 Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Sat, 17 Oct 2015 22:20:36 -0700 Subject: [PATCH] rafthttp: make ConnReadLimitByte private and add comment --- rafthttp/http.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/rafthttp/http.go b/rafthttp/http.go index 52473a416..f91c59cd8 100644 --- a/rafthttp/http.go +++ b/rafthttp/http.go @@ -29,7 +29,13 @@ import ( ) const ( - ConnReadLimitByte = 64 * 1024 + // connReadLimitByte limits the number of bytes + // a single read can read out. + // + // 64KB should be large enough for not causing + // throughput bottleneck as well as small enough + // for not causing a read timeout. + connReadLimitByte = 64 * 1024 ) var ( @@ -94,8 +100,8 @@ func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } // Limit the data size that could be read from the request body, which ensures that read from - // connection will not time out accidentally due to possible block in underlying implementation. - limitedr := pioutil.NewLimitedBufferReader(r.Body, ConnReadLimitByte) + // connection will not time out accidentally due to possible blocking in underlying implementation. + limitedr := pioutil.NewLimitedBufferReader(r.Body, connReadLimitByte) b, err := ioutil.ReadAll(limitedr) if err != nil { plog.Errorf("failed to read raft message (%v)", err)