mirror of
				https://gitea.com/Lydanne/buildx.git
				synced 2025-11-04 10:03:42 +08:00 
			
		
		
		
	vendor: update buildkit to master@8b7bcb900d3c
Signed-off-by: Justin Chadwell <me@jedevc.com>
This commit is contained in:
		
							
								
								
									
										8
									
								
								vendor/github.com/containerd/ttrpc/Makefile
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										8
									
								
								vendor/github.com/containerd/ttrpc/Makefile
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -57,7 +57,7 @@ TESTFLAGS_PARALLEL ?= 8
 | 
			
		||||
# Use this to replace `go test` with, for instance, `gotestsum`
 | 
			
		||||
GOTEST ?= $(GO) test
 | 
			
		||||
 | 
			
		||||
.PHONY: clean all AUTHORS build binaries test integration generate protos checkprotos coverage ci check help install vendor install-protobuf install-protobuild
 | 
			
		||||
.PHONY: clean all AUTHORS build binaries test integration generate protos check-protos coverage ci check help install vendor install-protobuf install-protobuild
 | 
			
		||||
.DEFAULT: default
 | 
			
		||||
 | 
			
		||||
# Forcibly set the default goal to all, in case an include above brought in a rule definition.
 | 
			
		||||
@@ -69,7 +69,7 @@ check: proto-fmt ## run all linters
 | 
			
		||||
	@echo "$(WHALE) $@"
 | 
			
		||||
	GOGC=75 golangci-lint run
 | 
			
		||||
 | 
			
		||||
ci: check binaries checkprotos coverage # coverage-integration ## to be used by the CI
 | 
			
		||||
ci: check binaries check-protos coverage # coverage-integration ## to be used by the CI
 | 
			
		||||
 | 
			
		||||
AUTHORS: .mailmap .git/HEAD
 | 
			
		||||
	git log --format='%aN <%aE>' | sort -fu > $@
 | 
			
		||||
@@ -145,8 +145,8 @@ install-protobuf:
 | 
			
		||||
 | 
			
		||||
install-protobuild:
 | 
			
		||||
	@echo "$(WHALE) $@"
 | 
			
		||||
	@$(GO) install google.golang.org/protobuf/cmd/protoc-gen-go@v1.27.1
 | 
			
		||||
	@$(GO) install github.com/containerd/protobuild@7e5ee24bc1f70e9e289fef15e2631eb3491320bf
 | 
			
		||||
	@$(GO) install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28.1
 | 
			
		||||
	@$(GO) install github.com/containerd/protobuild@14832ccc41429f5c4f81028e5af08aa233a219cf
 | 
			
		||||
 | 
			
		||||
coverage: ## generate coverprofiles from the unit tests, except tests that require root
 | 
			
		||||
	@echo "$(WHALE) $@"
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										3
									
								
								vendor/github.com/containerd/ttrpc/Protobuild.toml
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								vendor/github.com/containerd/ttrpc/Protobuild.toml
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -23,3 +23,6 @@ generators = ["go"]
 | 
			
		||||
# enable ttrpc and disable fieldpath and grpc for the shim
 | 
			
		||||
prefixes = ["github.com/containerd/ttrpc/integration/streaming"]
 | 
			
		||||
generators = ["go", "go-ttrpc"]
 | 
			
		||||
 | 
			
		||||
[overrides.parameters.go-ttrpc]
 | 
			
		||||
prefix = "TTRPC"
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										4
									
								
								vendor/github.com/containerd/ttrpc/README.md
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								vendor/github.com/containerd/ttrpc/README.md
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,7 +1,6 @@
 | 
			
		||||
# ttrpc
 | 
			
		||||
 | 
			
		||||
[](https://github.com/containerd/ttrpc/actions?query=workflow%3ACI)
 | 
			
		||||
[](https://codecov.io/gh/containerd/ttrpc)
 | 
			
		||||
 | 
			
		||||
GRPC for low-memory environments.
 | 
			
		||||
 | 
			
		||||
@@ -30,7 +29,7 @@ Create a gogo vanity binary (see
 | 
			
		||||
[`cmd/protoc-gen-gogottrpc/main.go`](cmd/protoc-gen-gogottrpc/main.go) for an
 | 
			
		||||
example with the ttrpc plugin enabled.
 | 
			
		||||
 | 
			
		||||
It's recommended to use [`protobuild`](https://github.com//stevvooe/protobuild)
 | 
			
		||||
It's recommended to use [`protobuild`](https://github.com/containerd/protobuild)
 | 
			
		||||
to build the protobufs for this project, but this will work with protoc
 | 
			
		||||
directly, if required.
 | 
			
		||||
 | 
			
		||||
@@ -41,7 +40,6 @@ directly, if required.
 | 
			
		||||
- The client and server interface are identical whereas in GRPC there is a
 | 
			
		||||
  client and server interface that are different.
 | 
			
		||||
- The Go stdlib context package is used instead.
 | 
			
		||||
- No support for streams yet.
 | 
			
		||||
 | 
			
		||||
# Status
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										4
									
								
								vendor/github.com/containerd/ttrpc/request.pb.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								vendor/github.com/containerd/ttrpc/request.pb.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,7 +1,7 @@
 | 
			
		||||
// Code generated by protoc-gen-go. DO NOT EDIT.
 | 
			
		||||
// versions:
 | 
			
		||||
// 	protoc-gen-go v1.27.1
 | 
			
		||||
// 	protoc        v3.11.4
 | 
			
		||||
// 	protoc-gen-go v1.28.1
 | 
			
		||||
// 	protoc        v3.20.1
 | 
			
		||||
// source: github.com/containerd/ttrpc/request.proto
 | 
			
		||||
 | 
			
		||||
package ttrpc
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										62
									
								
								vendor/github.com/containerd/ttrpc/server.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										62
									
								
								vendor/github.com/containerd/ttrpc/server.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -18,11 +18,13 @@ package ttrpc
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"io"
 | 
			
		||||
	"math/rand"
 | 
			
		||||
	"net"
 | 
			
		||||
	"sync"
 | 
			
		||||
	"sync/atomic"
 | 
			
		||||
	"syscall"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"github.com/sirupsen/logrus"
 | 
			
		||||
@@ -119,12 +121,18 @@ func (s *Server) Serve(ctx context.Context, l net.Listener) error {
 | 
			
		||||
 | 
			
		||||
		approved, handshake, err := handshaker.Handshake(ctx, conn)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			logrus.WithError(err).Errorf("ttrpc: refusing connection after handshake")
 | 
			
		||||
			logrus.WithError(err).Error("ttrpc: refusing connection after handshake")
 | 
			
		||||
			conn.Close()
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		sc, err := s.newConn(approved, handshake)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			logrus.WithError(err).Error("ttrpc: create connection failed")
 | 
			
		||||
			conn.Close()
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		sc := s.newConn(approved, handshake)
 | 
			
		||||
		go sc.run(ctx)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -143,15 +151,20 @@ func (s *Server) Shutdown(ctx context.Context) error {
 | 
			
		||||
	ticker := time.NewTicker(200 * time.Millisecond)
 | 
			
		||||
	defer ticker.Stop()
 | 
			
		||||
	for {
 | 
			
		||||
		if s.closeIdleConns() {
 | 
			
		||||
			return lnerr
 | 
			
		||||
		s.closeIdleConns()
 | 
			
		||||
 | 
			
		||||
		if s.countConnection() == 0 {
 | 
			
		||||
			break
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		select {
 | 
			
		||||
		case <-ctx.Done():
 | 
			
		||||
			return ctx.Err()
 | 
			
		||||
		case <-ticker.C:
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return lnerr
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Close the server without waiting for active connections.
 | 
			
		||||
@@ -203,11 +216,18 @@ func (s *Server) closeListeners() error {
 | 
			
		||||
	return err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *Server) addConnection(c *serverConn) {
 | 
			
		||||
func (s *Server) addConnection(c *serverConn) error {
 | 
			
		||||
	s.mu.Lock()
 | 
			
		||||
	defer s.mu.Unlock()
 | 
			
		||||
 | 
			
		||||
	select {
 | 
			
		||||
	case <-s.done:
 | 
			
		||||
		return ErrServerClosed
 | 
			
		||||
	default:
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	s.connections[c] = struct{}{}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *Server) delConnection(c *serverConn) {
 | 
			
		||||
@@ -224,20 +244,17 @@ func (s *Server) countConnection() int {
 | 
			
		||||
	return len(s.connections)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *Server) closeIdleConns() bool {
 | 
			
		||||
func (s *Server) closeIdleConns() {
 | 
			
		||||
	s.mu.Lock()
 | 
			
		||||
	defer s.mu.Unlock()
 | 
			
		||||
	quiescent := true
 | 
			
		||||
 | 
			
		||||
	for c := range s.connections {
 | 
			
		||||
		st, ok := c.getState()
 | 
			
		||||
		if !ok || st != connStateIdle {
 | 
			
		||||
			quiescent = false
 | 
			
		||||
		if st, ok := c.getState(); !ok || st == connStateActive {
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
		c.close()
 | 
			
		||||
		delete(s.connections, c)
 | 
			
		||||
	}
 | 
			
		||||
	return quiescent
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type connState int
 | 
			
		||||
@@ -261,7 +278,7 @@ func (cs connState) String() string {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *Server) newConn(conn net.Conn, handshake interface{}) *serverConn {
 | 
			
		||||
func (s *Server) newConn(conn net.Conn, handshake interface{}) (*serverConn, error) {
 | 
			
		||||
	c := &serverConn{
 | 
			
		||||
		server:    s,
 | 
			
		||||
		conn:      conn,
 | 
			
		||||
@@ -269,8 +286,11 @@ func (s *Server) newConn(conn net.Conn, handshake interface{}) *serverConn {
 | 
			
		||||
		shutdown:  make(chan struct{}),
 | 
			
		||||
	}
 | 
			
		||||
	c.setState(connStateIdle)
 | 
			
		||||
	s.addConnection(c)
 | 
			
		||||
	return c
 | 
			
		||||
	if err := s.addConnection(c); err != nil {
 | 
			
		||||
		c.close()
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	return c, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type serverConn struct {
 | 
			
		||||
@@ -318,6 +338,7 @@ func (c *serverConn) run(sctx context.Context) {
 | 
			
		||||
		responses              = make(chan response)
 | 
			
		||||
		recvErr                = make(chan error, 1)
 | 
			
		||||
		done                   = make(chan struct{})
 | 
			
		||||
		streams                = sync.Map{}
 | 
			
		||||
		active       int32
 | 
			
		||||
		lastStreamID uint32
 | 
			
		||||
	)
 | 
			
		||||
@@ -347,7 +368,6 @@ func (c *serverConn) run(sctx context.Context) {
 | 
			
		||||
 | 
			
		||||
	go func(recvErr chan error) {
 | 
			
		||||
		defer close(recvErr)
 | 
			
		||||
		streams := map[uint32]*streamHandler{}
 | 
			
		||||
		for {
 | 
			
		||||
			select {
 | 
			
		||||
			case <-c.shutdown:
 | 
			
		||||
@@ -383,12 +403,13 @@ func (c *serverConn) run(sctx context.Context) {
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if mh.Type == messageTypeData {
 | 
			
		||||
				sh, ok := streams[mh.StreamID]
 | 
			
		||||
				i, ok := streams.Load(mh.StreamID)
 | 
			
		||||
				if !ok {
 | 
			
		||||
					if !sendStatus(mh.StreamID, status.Newf(codes.InvalidArgument, "StreamID is no longer active")) {
 | 
			
		||||
						return
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
				sh := i.(*streamHandler)
 | 
			
		||||
				if mh.Flags&flagNoData != flagNoData {
 | 
			
		||||
					unmarshal := func(obj interface{}) error {
 | 
			
		||||
						err := protoUnmarshal(p, obj)
 | 
			
		||||
@@ -458,7 +479,7 @@ func (c *serverConn) run(sctx context.Context) {
 | 
			
		||||
					continue
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				streams[id] = sh
 | 
			
		||||
				streams.Store(id, sh)
 | 
			
		||||
				atomic.AddInt32(&active, 1)
 | 
			
		||||
			}
 | 
			
		||||
			// TODO: else we must ignore this for future compat. log this?
 | 
			
		||||
@@ -518,6 +539,7 @@ func (c *serverConn) run(sctx context.Context) {
 | 
			
		||||
				// The ttrpc protocol currently does not support the case where
 | 
			
		||||
				// the server is localClosed but not remoteClosed. Once the server
 | 
			
		||||
				// is closing, the whole stream may be considered finished
 | 
			
		||||
				streams.Delete(response.id)
 | 
			
		||||
				atomic.AddInt32(&active, -1)
 | 
			
		||||
			}
 | 
			
		||||
		case err := <-recvErr:
 | 
			
		||||
@@ -525,14 +547,12 @@ func (c *serverConn) run(sctx context.Context) {
 | 
			
		||||
			// branch. Basically, it means that we are no longer receiving
 | 
			
		||||
			// requests due to a terminal error.
 | 
			
		||||
			recvErr = nil // connection is now "closing"
 | 
			
		||||
			if err == io.EOF || err == io.ErrUnexpectedEOF {
 | 
			
		||||
			if err == io.EOF || err == io.ErrUnexpectedEOF || errors.Is(err, syscall.ECONNRESET) {
 | 
			
		||||
				// The client went away and we should stop processing
 | 
			
		||||
				// requests, so that the client connection is closed
 | 
			
		||||
				return
 | 
			
		||||
			}
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				logrus.WithError(err).Error("error receiving message")
 | 
			
		||||
			}
 | 
			
		||||
			logrus.WithError(err).Error("error receiving message")
 | 
			
		||||
			// else, initiate shutdown
 | 
			
		||||
		case <-shutdown:
 | 
			
		||||
			return
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user