Explorar o código

v3rpc: limit recv size using MaxRecvMsgSize and send using MaxSendMsgSize

grpc 1.3 uses MaxMsgSize() to limit received message size. However, grpc 1.4 introduces a 4mb default limit on send message size. In etcd, server shouldn't be limit size of message that it can be sent. Hence, set maximum size of send message using MaxSendMsgSize().
fanmin shi %!s(int64=8) %!d(string=hai) anos
pai
achega
d2ca782277
Modificáronse 1 ficheiros con 3 adicións e 1 borrados
  1. 3 1
      etcdserver/api/v3rpc/grpc.go

+ 3 - 1
etcdserver/api/v3rpc/grpc.go

@@ -31,6 +31,7 @@ import (
 const (
 const (
 	grpcOverheadBytes = 512 * 1024
 	grpcOverheadBytes = 512 * 1024
 	maxStreams        = math.MaxUint32
 	maxStreams        = math.MaxUint32
+	maxSendBytes      = math.MaxInt32
 )
 )
 
 
 func init() {
 func init() {
@@ -45,7 +46,8 @@ func Server(s *etcdserver.EtcdServer, tls *tls.Config) *grpc.Server {
 	}
 	}
 	opts = append(opts, grpc.UnaryInterceptor(newUnaryInterceptor(s)))
 	opts = append(opts, grpc.UnaryInterceptor(newUnaryInterceptor(s)))
 	opts = append(opts, grpc.StreamInterceptor(newStreamInterceptor(s)))
 	opts = append(opts, grpc.StreamInterceptor(newStreamInterceptor(s)))
-	opts = append(opts, grpc.MaxMsgSize(int(s.Cfg.MaxRequestBytes+grpcOverheadBytes)))
+	opts = append(opts, grpc.MaxRecvMsgSize(int(s.Cfg.MaxRequestBytes+grpcOverheadBytes)))
+	opts = append(opts, grpc.MaxSendMsgSize(maxSendBytes))
 	opts = append(opts, grpc.MaxConcurrentStreams(maxStreams))
 	opts = append(opts, grpc.MaxConcurrentStreams(maxStreams))
 	grpcServer := grpc.NewServer(opts...)
 	grpcServer := grpc.NewServer(opts...)