ListenRangeConfig.Listen: move trying port log after fslock trylock for less logs

This commit is contained in:
Adrien Delorme 2019-04-30 15:35:22 +02:00
parent 79ae62801f
commit fd63ec9a6c
1 changed files with 2 additions and 2 deletions

View File

@ -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 {