Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'internal/grpc/backchannel')
-rw-r--r--internal/grpc/backchannel/backchannel.go7
-rw-r--r--internal/grpc/backchannel/client.go6
-rw-r--r--internal/grpc/backchannel/server.go9
3 files changed, 7 insertions, 15 deletions
diff --git a/internal/grpc/backchannel/backchannel.go b/internal/grpc/backchannel/backchannel.go
index 990e3e5fb..627a492d2 100644
--- a/internal/grpc/backchannel/backchannel.go
+++ b/internal/grpc/backchannel/backchannel.go
@@ -29,20 +29,21 @@
package backchannel
import (
- "io"
"net"
"sync"
"github.com/hashicorp/yamux"
+ "github.com/sirupsen/logrus"
)
// magicBytes are sent by the client to server to identify as a multiplexing aware client.
var magicBytes = []byte("backchannel")
// muxConfig returns a new config to use with the multiplexing session.
-func muxConfig(logger io.Writer, cfg Configuration) *yamux.Config {
+func muxConfig(logger logrus.FieldLogger, cfg Configuration) *yamux.Config {
yamuxCfg := yamux.DefaultConfig()
- yamuxCfg.LogOutput = logger
+ yamuxCfg.Logger = logger
+ yamuxCfg.LogOutput = nil
// gRPC is already configured to send keep alives so we don't need yamux to do this for us.
// gRPC is a better choice as it sends the keep alives also to non-multiplexed connections.
yamuxCfg.EnableKeepAlive = false
diff --git a/internal/grpc/backchannel/client.go b/internal/grpc/backchannel/client.go
index fe3ff8a77..f6f3d0663 100644
--- a/internal/grpc/backchannel/client.go
+++ b/internal/grpc/backchannel/client.go
@@ -115,18 +115,14 @@ func (ch clientHandshake) serve(ctx context.Context, conn net.Conn) (net.Conn, e
return nil, fmt.Errorf("write backchannel magic bytes: %w", err)
}
- logger := ch.logger.WithField("component", "backchannel.YamuxClient").WriterLevel(logrus.ErrorLevel)
-
// Initiate the multiplexing session.
- muxSession, err := yamux.Client(conn, muxConfig(logger, ch.cfg))
+ muxSession, err := yamux.Client(conn, muxConfig(ch.logger.WithField("component", "backchannel.YamuxClient"), ch.cfg))
if err != nil {
- logger.Close()
return nil, fmt.Errorf("open multiplexing session: %w", err)
}
go func() {
<-muxSession.CloseChan()
- logger.Close()
}()
// Initiate the stream to the server. This is used by the client's gRPC session.
diff --git a/internal/grpc/backchannel/server.go b/internal/grpc/backchannel/server.go
index 44e2e6405..4e815e07f 100644
--- a/internal/grpc/backchannel/server.go
+++ b/internal/grpc/backchannel/server.go
@@ -99,8 +99,6 @@ func (s *ServerHandshaker) Handshake(conn net.Conn, authInfo credentials.AuthInf
// gRPC server closes the conn if there is an error, which closes the multiplexing
// session as well.
- logger := s.logger.WithField("component", "backchannel.YamuxServer").WriterLevel(logrus.ErrorLevel)
-
// Open the server side of the multiplexing session.
//
// Gitaly is using custom settings with a lower accept backlog and higher receive
@@ -109,16 +107,14 @@ func (s *ServerHandshaker) Handshake(conn net.Conn, authInfo credentials.AuthInf
cfg := DefaultConfiguration()
cfg.AcceptBacklog = 1
cfg.MaximumStreamWindowSizeBytes = 16 * 1024 * 1024
- muxSession, err := yamux.Server(conn, muxConfig(logger, cfg))
+ muxSession, err := yamux.Server(conn, muxConfig(s.logger.WithField("component", "backchannel.YamuxServer"), cfg))
if err != nil {
- logger.Close()
return nil, nil, fmt.Errorf("create multiplexing session: %w", err)
}
// Accept the client's stream. This is the client's gRPC session to the server.
clientToServerStream, err := muxSession.Accept()
if err != nil {
- logger.Close()
return nil, nil, fmt.Errorf("accept client's stream: %w", err)
}
@@ -133,7 +129,6 @@ func (s *ServerHandshaker) Handshake(conn net.Conn, authInfo credentials.AuthInf
)...,
)
if err != nil {
- logger.Close()
return nil, nil, fmt.Errorf("dial backchannel: %w", err)
}
@@ -147,7 +142,7 @@ func (s *ServerHandshaker) Handshake(conn net.Conn, authInfo credentials.AuthInf
var firstErr error
for _, closer := range []io.Closer{
- backchannelConn, muxSession, logger,
+ backchannelConn, muxSession,
} {
if err := closer.Close(); err != nil && firstErr == nil {
firstErr = err