aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/hashicorp/go-plugin
diff options
context:
space:
mode:
authorAlexandre Garand <alexandre.garand@fretlink.com>2019-08-09 15:59:15 +0200
committerAlexandre Garand <alexandre.garand@fretlink.com>2019-08-09 16:39:21 +0200
commit863486a6b71ed0e562a3965bed56465d007b1418 (patch)
treee93f6a687695af86d54237ec9f575d4ef104222d /vendor/github.com/hashicorp/go-plugin
parent49c1c7b4dc69ffb9ab52330e6dc52ccdd6351087 (diff)
downloadterraform-provider-statuscake-add_contact_groups.tar.gz
terraform-provider-statuscake-add_contact_groups.tar.zst
terraform-provider-statuscake-add_contact_groups.zip
update vendor and go.modadd_contact_groups
Diffstat (limited to 'vendor/github.com/hashicorp/go-plugin')
-rw-r--r--vendor/github.com/hashicorp/go-plugin/client.go20
-rw-r--r--vendor/github.com/hashicorp/go-plugin/server.go32
2 files changed, 41 insertions, 11 deletions
diff --git a/vendor/github.com/hashicorp/go-plugin/client.go b/vendor/github.com/hashicorp/go-plugin/client.go
index 679e10a..bc56559 100644
--- a/vendor/github.com/hashicorp/go-plugin/client.go
+++ b/vendor/github.com/hashicorp/go-plugin/client.go
@@ -87,6 +87,10 @@ type Client struct {
87 // goroutines. 87 // goroutines.
88 clientWaitGroup sync.WaitGroup 88 clientWaitGroup sync.WaitGroup
89 89
90 // stderrWaitGroup is used to prevent the command's Wait() function from
91 // being called before we've finished reading from the stderr pipe.
92 stderrWaitGroup sync.WaitGroup
93
90 // processKilled is used for testing only, to flag when the process was 94 // processKilled is used for testing only, to flag when the process was
91 // forcefully killed. 95 // forcefully killed.
92 processKilled bool 96 processKilled bool
@@ -590,6 +594,12 @@ func (c *Client) Start() (addr net.Addr, err error) {
590 // Create a context for when we kill 594 // Create a context for when we kill
591 c.doneCtx, c.ctxCancel = context.WithCancel(context.Background()) 595 c.doneCtx, c.ctxCancel = context.WithCancel(context.Background())
592 596
597 // Start goroutine that logs the stderr
598 c.clientWaitGroup.Add(1)
599 c.stderrWaitGroup.Add(1)
600 // logStderr calls Done()
601 go c.logStderr(cmdStderr)
602
593 c.clientWaitGroup.Add(1) 603 c.clientWaitGroup.Add(1)
594 go func() { 604 go func() {
595 // ensure the context is cancelled when we're done 605 // ensure the context is cancelled when we're done
@@ -602,6 +612,10 @@ func (c *Client) Start() (addr net.Addr, err error) {
602 pid := c.process.Pid 612 pid := c.process.Pid
603 path := cmd.Path 613 path := cmd.Path
604 614
615 // wait to finish reading from stderr since the stderr pipe reader
616 // will be closed by the subsequent call to cmd.Wait().
617 c.stderrWaitGroup.Wait()
618
605 // Wait for the command to end. 619 // Wait for the command to end.
606 err := cmd.Wait() 620 err := cmd.Wait()
607 621
@@ -624,11 +638,6 @@ func (c *Client) Start() (addr net.Addr, err error) {
624 c.exited = true 638 c.exited = true
625 }() 639 }()
626 640
627 // Start goroutine that logs the stderr
628 c.clientWaitGroup.Add(1)
629 // logStderr calls Done()
630 go c.logStderr(cmdStderr)
631
632 // Start a goroutine that is going to be reading the lines 641 // Start a goroutine that is going to be reading the lines
633 // out of stdout 642 // out of stdout
634 linesCh := make(chan string) 643 linesCh := make(chan string)
@@ -936,6 +945,7 @@ var stdErrBufferSize = 64 * 1024
936 945
937func (c *Client) logStderr(r io.Reader) { 946func (c *Client) logStderr(r io.Reader) {
938 defer c.clientWaitGroup.Done() 947 defer c.clientWaitGroup.Done()
948 defer c.stderrWaitGroup.Done()
939 l := c.logger.Named(filepath.Base(c.config.Cmd.Path)) 949 l := c.logger.Named(filepath.Base(c.config.Cmd.Path))
940 950
941 reader := bufio.NewReaderSize(r, stdErrBufferSize) 951 reader := bufio.NewReaderSize(r, stdErrBufferSize)
diff --git a/vendor/github.com/hashicorp/go-plugin/server.go b/vendor/github.com/hashicorp/go-plugin/server.go
index fc9f05a..4c230e3 100644
--- a/vendor/github.com/hashicorp/go-plugin/server.go
+++ b/vendor/github.com/hashicorp/go-plugin/server.go
@@ -363,14 +363,34 @@ func serverListener() (net.Listener, error) {
363} 363}
364 364
365func serverListener_tcp() (net.Listener, error) { 365func serverListener_tcp() (net.Listener, error) {
366 minPort, err := strconv.ParseInt(os.Getenv("PLUGIN_MIN_PORT"), 10, 32) 366 envMinPort := os.Getenv("PLUGIN_MIN_PORT")
367 if err != nil { 367 envMaxPort := os.Getenv("PLUGIN_MAX_PORT")
368 return nil, err 368
369 var minPort, maxPort int64
370 var err error
371
372 switch {
373 case len(envMinPort) == 0:
374 minPort = 0
375 default:
376 minPort, err = strconv.ParseInt(envMinPort, 10, 32)
377 if err != nil {
378 return nil, fmt.Errorf("Couldn't get value from PLUGIN_MIN_PORT: %v", err)
379 }
369 } 380 }
370 381
371 maxPort, err := strconv.ParseInt(os.Getenv("PLUGIN_MAX_PORT"), 10, 32) 382 switch {
372 if err != nil { 383 case len(envMaxPort) == 0:
373 return nil, err 384 maxPort = 0
385 default:
386 maxPort, err = strconv.ParseInt(envMaxPort, 10, 32)
387 if err != nil {
388 return nil, fmt.Errorf("Couldn't get value from PLUGIN_MAX_PORT: %v", err)
389 }
390 }
391
392 if minPort > maxPort {
393 return nil, fmt.Errorf("ENV_MIN_PORT value of %d is greater than PLUGIN_MAX_PORT value of %d", minPort, maxPort)
374 } 394 }
375 395
376 for port := minPort; port <= maxPort; port++ { 396 for port := minPort; port <= maxPort; port++ {