Vendor Microsoft/hcsshim with CGO removal
Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
This commit is contained in:
		
							
								
								
									
										7
									
								
								vendor/github.com/Microsoft/hcsshim/internal/hcs/cgo.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								vendor/github.com/Microsoft/hcsshim/internal/hcs/cgo.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,7 +0,0 @@
 | 
			
		||||
package hcs
 | 
			
		||||
 | 
			
		||||
import "C"
 | 
			
		||||
 | 
			
		||||
// This import is needed to make the library compile as CGO because HCSSHIM
 | 
			
		||||
// only works with CGO due to callbacks from HCS comming back from a C thread
 | 
			
		||||
// which is not supported without CGO. See https://github.com/golang/go/issues/10973
 | 
			
		||||
							
								
								
									
										50
									
								
								vendor/github.com/Microsoft/hcsshim/internal/hcs/system.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										50
									
								
								vendor/github.com/Microsoft/hcsshim/internal/hcs/system.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -4,12 +4,9 @@ import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"os"
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"strings"
 | 
			
		||||
	"sync"
 | 
			
		||||
	"syscall"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"github.com/Microsoft/hcsshim/internal/cow"
 | 
			
		||||
	"github.com/Microsoft/hcsshim/internal/log"
 | 
			
		||||
@@ -21,27 +18,6 @@ import (
 | 
			
		||||
	"go.opencensus.io/trace"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// currentContainerStarts is used to limit the number of concurrent container
 | 
			
		||||
// starts.
 | 
			
		||||
var currentContainerStarts containerStarts
 | 
			
		||||
 | 
			
		||||
type containerStarts struct {
 | 
			
		||||
	maxParallel int
 | 
			
		||||
	inProgress  int
 | 
			
		||||
	sync.Mutex
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func init() {
 | 
			
		||||
	mpsS := os.Getenv("HCSSHIM_MAX_PARALLEL_START")
 | 
			
		||||
	if len(mpsS) > 0 {
 | 
			
		||||
		mpsI, err := strconv.Atoi(mpsS)
 | 
			
		||||
		if err != nil || mpsI < 0 {
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
		currentContainerStarts.maxParallel = mpsI
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type System struct {
 | 
			
		||||
	handleLock     sync.RWMutex
 | 
			
		||||
	handle         vmcompute.HcsSystem
 | 
			
		||||
@@ -215,32 +191,6 @@ func (computeSystem *System) Start(ctx context.Context) (err error) {
 | 
			
		||||
		return makeSystemError(computeSystem, operation, "", ErrAlreadyClosed, nil)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// This is a very simple backoff-retry loop to limit the number
 | 
			
		||||
	// of parallel container starts if environment variable
 | 
			
		||||
	// HCSSHIM_MAX_PARALLEL_START is set to a positive integer.
 | 
			
		||||
	// It should generally only be used as a workaround to various
 | 
			
		||||
	// platform issues that exist between RS1 and RS4 as of Aug 2018
 | 
			
		||||
	if currentContainerStarts.maxParallel > 0 {
 | 
			
		||||
		for {
 | 
			
		||||
			currentContainerStarts.Lock()
 | 
			
		||||
			if currentContainerStarts.inProgress < currentContainerStarts.maxParallel {
 | 
			
		||||
				currentContainerStarts.inProgress++
 | 
			
		||||
				currentContainerStarts.Unlock()
 | 
			
		||||
				break
 | 
			
		||||
			}
 | 
			
		||||
			if currentContainerStarts.inProgress == currentContainerStarts.maxParallel {
 | 
			
		||||
				currentContainerStarts.Unlock()
 | 
			
		||||
				time.Sleep(100 * time.Millisecond)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		// Make sure we decrement the count when we are done.
 | 
			
		||||
		defer func() {
 | 
			
		||||
			currentContainerStarts.Lock()
 | 
			
		||||
			currentContainerStarts.inProgress--
 | 
			
		||||
			currentContainerStarts.Unlock()
 | 
			
		||||
		}()
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	resultJSON, err := vmcompute.HcsStartComputeSystem(ctx, computeSystem.handle, "")
 | 
			
		||||
	events, err := processAsyncHcsResult(ctx, err, resultJSON, computeSystem.callbackNumber, hcsNotificationSystemStartCompleted, &timeout.SystemStart)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user