Kaynağa Gözat

v3rpc: Let clients establish unlimited streams

From go-grpc v1.2.0, the number of max streams per client is set to 100
by default by the server side. This change makes it impossible
for third party proxies and custom clients to establish many streams.
Iwasaki Yudai 9 yıl önce
ebeveyn
işleme
52101e6e93
1 değiştirilmiş dosya ile 6 ekleme ve 1 silme
  1. 6 1
      etcdserver/api/v3rpc/grpc.go

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

@@ -16,6 +16,7 @@ package v3rpc
 
 
 import (
 import (
 	"crypto/tls"
 	"crypto/tls"
+	"math"
 
 
 	"github.com/coreos/etcd/etcdserver"
 	"github.com/coreos/etcd/etcdserver"
 	pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
 	pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
@@ -27,7 +28,10 @@ import (
 	healthpb "google.golang.org/grpc/health/grpc_health_v1"
 	healthpb "google.golang.org/grpc/health/grpc_health_v1"
 )
 )
 
 
-const grpcOverheadBytes = 512 * 1024
+const (
+	grpcOverheadBytes = 512 * 1024
+	maxStreams        = math.MaxUint32
+)
 
 
 func init() {
 func init() {
 	grpclog.SetLogger(plog)
 	grpclog.SetLogger(plog)
@@ -42,6 +46,7 @@ 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.MaxMsgSize(int(s.Cfg.MaxRequestBytes+grpcOverheadBytes)))
+	opts = append(opts, grpc.MaxConcurrentStreams(maxStreams))
 	grpcServer := grpc.NewServer(opts...)
 	grpcServer := grpc.NewServer(opts...)
 
 
 	pb.RegisterKVServer(grpcServer, NewQuotaKVServer(s))
 	pb.RegisterKVServer(grpcServer, NewQuotaKVServer(s))