Update to avoid pseudo-random number (#5225)
* Update to avoid pseudo-random number This PR update the usage of rand so that non-global seed is used. Signed-off-by: Yong Tang <yong.tang.github@outlook.com> * Add concurrency-safe random source See https://stackoverflow.com/questions/48958886/how-to-create-a-thread-safe-rand-source Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
parent
c3b30cc3ef
commit
aa7818e1d3
4 changed files with 52 additions and 8 deletions
|
@ -1,7 +1,6 @@
|
|||
package loop
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"net"
|
||||
"strconv"
|
||||
"time"
|
||||
|
@ -10,6 +9,7 @@ import (
|
|||
"github.com/coredns/coredns/core/dnsserver"
|
||||
"github.com/coredns/coredns/plugin"
|
||||
"github.com/coredns/coredns/plugin/pkg/dnsutil"
|
||||
"github.com/coredns/coredns/plugin/pkg/rand"
|
||||
)
|
||||
|
||||
func init() { plugin.Register("loop", setup) }
|
||||
|
@ -84,4 +84,4 @@ func qname(zone string) string {
|
|||
return dnsutil.Join(l1, l2, zone)
|
||||
}
|
||||
|
||||
var r = rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||
var r = rand.New(time.Now().UnixNano())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue