mirror of
https://github.com/cwinfo/yggdrasil-map
synced 2025-08-14 15:58:10 +00:00
add histogramming code, update crawler, allow longer names
This commit is contained in:
@@ -13,6 +13,13 @@ var visited sync.Map
|
||||
var rumored sync.Map
|
||||
|
||||
const MAX_RETRY = 3
|
||||
const N_PARALLEL_REQ = 32
|
||||
|
||||
var semaphore chan struct{}
|
||||
|
||||
func init() {
|
||||
semaphore = make(chan struct{}, N_PARALLEL_REQ)
|
||||
}
|
||||
|
||||
func dial() (net.Conn, error) {
|
||||
return net.DialTimeout("unix", "/var/run/yggdrasil.sock", time.Second)
|
||||
@@ -85,6 +92,8 @@ func doRumor(key string, out chan rumorResult) {
|
||||
waitgroup.Add(1)
|
||||
go func() {
|
||||
defer waitgroup.Done()
|
||||
semaphore<-struct{}{}
|
||||
defer func() { <-semaphore }()
|
||||
if _, known := rumored.LoadOrStore(key, true); known {
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user