From fd63ec9a6c22239514a07146dd8500ac4fcf0f41 Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Tue, 30 Apr 2019 15:35:22 +0200 Subject: [PATCH] ListenRangeConfig.Listen: move trying port log after fslock trylock for less logs --- common/net/configure_port.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/net/configure_port.go b/common/net/configure_port.go index 1d6050081..51765fda6 100644 --- a/common/net/configure_port.go +++ b/common/net/configure_port.go @@ -65,8 +65,6 @@ func (lc ListenRangeConfig) Listen(ctx context.Context) (*Listener, error) { port += rand.Intn(portRange) } - log.Printf("Trying port: %d", port) - lockFilePath, err := packer.CachePath("port", strconv.Itoa(port)) if err != nil { return nil, err @@ -81,6 +79,8 @@ func (lc ListenRangeConfig) Listen(ctx context.Context) (*Listener, error) { continue // this port seems to be locked by another packer goroutine } + log.Printf("Trying port: %d", port) + l, err := lc.ListenConfig.Listen(ctx, lc.Network, fmt.Sprintf("%s:%d", lc.Addr, port)) if err != nil { if err := lock.Unlock(); err != nil {