Skip to content

Commit

Permalink
when listen.port is zero, fix multiple routines (#1057)
Browse files Browse the repository at this point in the history
This used to work correctly because when the multiple routines work was
first added in #382, but an important part to discover the listen port
before opening the other listeners on the same socket was lost in this
PR: #653.

This change should fix the regression and allow multiple routines to
work correctly when listen.port is set to `0`.

Thanks to @rawdigits for tracking down and discovering this regression.
  • Loading branch information
wadey authored Jan 8, 2024
1 parent b22ba6e commit 0564d0a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,16 @@ func Main(c *config.C, configTest bool, buildVersion string, logger *logrus.Logg
}
udpServer.ReloadConfig(c)
udpConns[i] = udpServer

// If port is dynamic, discover it before the next pass through the for loop
// This way all routines will use the same port correctly
if port == 0 {
uPort, err := udpServer.LocalAddr()
if err != nil {
return nil, util.NewContextualError("Failed to get listening port", nil, err)
}
port = int(uPort.Port)
}
}
}

Expand Down

0 comments on commit 0564d0a

Please sign in to comment.