mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
rafthttp: make ConnReadLimitByte private and add comment
This commit is contained in:
parent
d07c9b00e5
commit
080c11d14e
@ -29,7 +29,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
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 (
|
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
|
// 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.
|
// connection will not time out accidentally due to possible blocking in underlying implementation.
|
||||||
limitedr := pioutil.NewLimitedBufferReader(r.Body, ConnReadLimitByte)
|
limitedr := pioutil.NewLimitedBufferReader(r.Body, connReadLimitByte)
|
||||||
b, err := ioutil.ReadAll(limitedr)
|
b, err := ioutil.ReadAll(limitedr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
plog.Errorf("failed to read raft message (%v)", err)
|
plog.Errorf("failed to read raft message (%v)", err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user