mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2025-07-06 06:24:06 +00:00
Support notifying components for config reload, listen for SIGHUP
This commit is contained in:
@ -162,6 +162,7 @@ type switchData struct {
|
||||
// All the information stored by the switch.
|
||||
type switchTable struct {
|
||||
core *Core
|
||||
reconfigure chan bool
|
||||
key crypto.SigPubKey // Our own key
|
||||
time time.Time // Time when locator.tstamp was last updated
|
||||
drop map[crypto.SigPubKey]int64 // Tstamp associated with a dropped root
|
||||
@ -184,6 +185,7 @@ const SwitchQueueTotalMinSize = 4 * 1024 * 1024
|
||||
func (t *switchTable) init(core *Core, key crypto.SigPubKey) {
|
||||
now := time.Now()
|
||||
t.core = core
|
||||
t.reconfigure = make(chan bool, 1)
|
||||
t.key = key
|
||||
locator := switchLocator{root: key, tstamp: now.Unix()}
|
||||
peers := make(map[switchPort]peerInfo)
|
||||
@ -808,6 +810,11 @@ func (t *switchTable) doWorker() {
|
||||
}
|
||||
case f := <-t.admin:
|
||||
f()
|
||||
case _ = <-t.reconfigure:
|
||||
t.core.configMutex.RLock()
|
||||
t.core.log.Println("Notified: switchTable")
|
||||
t.core.configMutex.RUnlock()
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user