Skip to content
Snippets Groups Projects
Commit d25ee4ac authored by Jake Taylor's avatar Jake Taylor
Browse files

manually connect new hosts added to the hostpool

parent 142724bf
No related branches found
No related tags found
3 merge requests!231Revert "Update store to print changes to the partners list",!187Xx 3829/triggers,!183manually connect new hosts added to the hostpool
...@@ -78,6 +78,7 @@ type PoolParams struct { ...@@ -78,6 +78,7 @@ type PoolParams struct {
PoolSize uint32 // Allows override of HostPool size. Set to zero for dynamic size calculation PoolSize uint32 // Allows override of HostPool size. Set to zero for dynamic size calculation
ProxyAttempts uint32 // How many proxies will be used in event of send failure ProxyAttempts uint32 // How many proxies will be used in event of send failure
MaxPings uint32 // How many gateways to concurrently test when initializing HostPool. Disabled if zero. MaxPings uint32 // How many gateways to concurrently test when initializing HostPool. Disabled if zero.
LazyConnection bool // Flag determining whether Host connections are initialized when added to HostPool
HostParams connect.HostParams // Parameters for the creation of new Host objects HostParams connect.HostParams // Parameters for the creation of new Host objects
} }
...@@ -88,6 +89,7 @@ func DefaultPoolParams() PoolParams { ...@@ -88,6 +89,7 @@ func DefaultPoolParams() PoolParams {
ProxyAttempts: 5, ProxyAttempts: 5,
PoolSize: 0, PoolSize: 0,
MaxPings: 0, MaxPings: 0,
LazyConnection: true,
HostParams: connect.GetDefaultHostParams(), HostParams: connect.GetDefaultHostParams(),
} }
p.HostParams.MaxRetries = 1 p.HostParams.MaxRetries = 1
...@@ -548,12 +550,14 @@ func (h *HostPool) replaceHostNoStore(newId *id.ID, oldPoolIndex uint32) error { ...@@ -548,12 +550,14 @@ func (h *HostPool) replaceHostNoStore(newId *id.ID, oldPoolIndex uint32) error {
} }
// Manually connect the new Host // Manually connect the new Host
if !h.poolParams.LazyConnection {
go func() { go func() {
err := newHost.Connect() err := newHost.Connect()
if err != nil { if err != nil {
jww.WARN.Printf("Unable to initialize Host connection: %+v", err) jww.WARN.Printf("Unable to initialize Host connection: %+v", err)
} }
}() }()
}
jww.DEBUG.Printf("Replaced Host at %d [%s] with new Host %s", oldPoolIndex, oldHostIDStr, jww.DEBUG.Printf("Replaced Host at %d [%s] with new Host %s", oldPoolIndex, oldHostIDStr,
newId.String()) newId.String())
...@@ -721,8 +725,8 @@ func readUint32(rng io.Reader) uint32 { ...@@ -721,8 +725,8 @@ func readUint32(rng io.Reader) uint32 {
func readRangeUint32(start, end uint32, rng io.Reader) uint32 { func readRangeUint32(start, end uint32, rng io.Reader) uint32 {
size := end - start size := end - start
// note we could just do the part inside the () here, but then extra // note we could just do the part inside the () here, but then extra
// can == size which means a little bit of range is wastes, either // can == size which means a little range is wasted, either
// choice seems negligible so we went with the "more correct" // choice seems negligible, so we went with the "more correct"
extra := (math.MaxUint32%size + 1) % size extra := (math.MaxUint32%size + 1) % size
limit := math.MaxUint32 - extra limit := math.MaxUint32 - extra
// Loop until we read something inside the limit // Loop until we read something inside the limit
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment