2
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								go.mod
									
									
									
									
									
								
							| @@ -18,7 +18,7 @@ require ( | ||||
| 	github.com/containerd/go-runc v1.0.0 | ||||
| 	github.com/containerd/imgcrypt v1.1.7 | ||||
| 	github.com/containerd/nri v0.3.0 | ||||
| 	github.com/containerd/ttrpc v1.2.0 | ||||
| 	github.com/containerd/ttrpc v1.2.1 | ||||
| 	github.com/containerd/typeurl/v2 v2.1.0 | ||||
| 	github.com/containerd/zfs v1.0.0 | ||||
| 	github.com/containernetworking/cni v1.1.2 | ||||
|   | ||||
							
								
								
									
										5
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								go.sum
									
									
									
									
									
								
							| @@ -276,8 +276,8 @@ github.com/containerd/ttrpc v0.0.0-20191028202541-4f1b8fe65a5c/go.mod h1:LPm1u0x | ||||
| github.com/containerd/ttrpc v1.0.1/go.mod h1:UAxOpgT9ziI0gJrmKvgcZivgxOp8iFPSk8httJEt98Y= | ||||
| github.com/containerd/ttrpc v1.0.2/go.mod h1:UAxOpgT9ziI0gJrmKvgcZivgxOp8iFPSk8httJEt98Y= | ||||
| github.com/containerd/ttrpc v1.1.0/go.mod h1:XX4ZTnoOId4HklF4edwc4DcqskFZuvXB1Evzy5KFQpQ= | ||||
| github.com/containerd/ttrpc v1.2.0 h1:we4O9wzVsBA1HUVRGU8CWFsbjy2P/U2g9raVu5XXNI0= | ||||
| github.com/containerd/ttrpc v1.2.0/go.mod h1:YYyNVhZrTMiaf51Vj6WhAJqJw+vl/nzABhj8pWrzle4= | ||||
| github.com/containerd/ttrpc v1.2.1 h1:VWv/Rzx023TBLv4WQ+9WPXlBG/s3rsRjY3i9AJ2BJdE= | ||||
| github.com/containerd/ttrpc v1.2.1/go.mod h1:sIT6l32Ph/H9cvnJsfXM5drIVzTr5A2flTf1G5tYZak= | ||||
| github.com/containerd/typeurl v0.0.0-20180627222232-a93fcdb778cd/go.mod h1:Cm3kwCdlkCfMSHURc+r6fwoGH6/F1hH3S4sg0rLFWPc= | ||||
| github.com/containerd/typeurl v0.0.0-20190911142611-5eb25027c9fd/go.mod h1:GeKYzf2pQcqv7tJ0AoCuuhtnqhva5LNU3U+OyKxxJpk= | ||||
| github.com/containerd/typeurl v1.0.1/go.mod h1:TB1hUtrpaiO88KEK56ijojHS1+NeF0izUACaJW2mdXg= | ||||
| @@ -1309,6 +1309,7 @@ golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBc | ||||
| golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= | ||||
| golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
|   | ||||
| @@ -9,7 +9,7 @@ require ( | ||||
| 	github.com/containerd/cgroups/v3 v3.0.1 | ||||
| 	github.com/containerd/containerd v1.7.0-beta.0 // see replace; the actual version of containerd is replaced with the code at the root of this repository | ||||
| 	github.com/containerd/go-runc v1.0.0 | ||||
| 	github.com/containerd/ttrpc v1.2.0 | ||||
| 	github.com/containerd/ttrpc v1.2.1 | ||||
| 	github.com/containerd/typeurl/v2 v2.1.0 | ||||
| 	github.com/opencontainers/go-digest v1.0.0 | ||||
| 	github.com/opencontainers/image-spec v1.1.0-rc2.0.20221005185240-3a7f492d3f1b | ||||
|   | ||||
| @@ -671,8 +671,8 @@ github.com/containerd/stargz-snapshotter/estargz v0.12.1/go.mod h1:12VUuCq3qPq4y | ||||
| github.com/containerd/ttrpc v1.0.2/go.mod h1:UAxOpgT9ziI0gJrmKvgcZivgxOp8iFPSk8httJEt98Y= | ||||
| github.com/containerd/ttrpc v1.1.0/go.mod h1:XX4ZTnoOId4HklF4edwc4DcqskFZuvXB1Evzy5KFQpQ= | ||||
| github.com/containerd/ttrpc v1.1.1-0.20220420014843-944ef4a40df3/go.mod h1:YYyNVhZrTMiaf51Vj6WhAJqJw+vl/nzABhj8pWrzle4= | ||||
| github.com/containerd/ttrpc v1.2.0 h1:we4O9wzVsBA1HUVRGU8CWFsbjy2P/U2g9raVu5XXNI0= | ||||
| github.com/containerd/ttrpc v1.2.0/go.mod h1:YYyNVhZrTMiaf51Vj6WhAJqJw+vl/nzABhj8pWrzle4= | ||||
| github.com/containerd/ttrpc v1.2.1 h1:VWv/Rzx023TBLv4WQ+9WPXlBG/s3rsRjY3i9AJ2BJdE= | ||||
| github.com/containerd/ttrpc v1.2.1/go.mod h1:sIT6l32Ph/H9cvnJsfXM5drIVzTr5A2flTf1G5tYZak= | ||||
| github.com/containerd/typeurl v1.0.1/go.mod h1:TB1hUtrpaiO88KEK56ijojHS1+NeF0izUACaJW2mdXg= | ||||
| github.com/containerd/typeurl v1.0.2/go.mod h1:9trJWW2sRlGub4wZJRTW83VtbOLS6hwcDZXTn6oPz9s= | ||||
| github.com/containerd/typeurl/v2 v2.1.0 h1:yNAhJvbNEANt7ck48IlEGOxP7YAp6LLpGn5jZACDNIE= | ||||
|   | ||||
							
								
								
									
										46
									
								
								vendor/github.com/containerd/ttrpc/server.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										46
									
								
								vendor/github.com/containerd/ttrpc/server.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -121,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) | ||||
| 	} | ||||
| } | ||||
| @@ -145,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. | ||||
| @@ -205,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) { | ||||
| @@ -226,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 | ||||
| @@ -263,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, | ||||
| @@ -271,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 { | ||||
|   | ||||
							
								
								
									
										2
									
								
								vendor/modules.txt
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/modules.txt
									
									
									
									
										vendored
									
									
								
							| @@ -137,7 +137,7 @@ github.com/containerd/nri/pkg/net/multiplex | ||||
| github.com/containerd/nri/pkg/runtime-tools/generate | ||||
| github.com/containerd/nri/pkg/stub | ||||
| github.com/containerd/nri/types/v1 | ||||
| # github.com/containerd/ttrpc v1.2.0 | ||||
| # github.com/containerd/ttrpc v1.2.1 | ||||
| ## explicit; go 1.13 | ||||
| github.com/containerd/ttrpc | ||||
| # github.com/containerd/typeurl v1.0.2 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Derek McGowan
					Derek McGowan