dont negotiate with everyone all the time
All checks were successful
Build and Publish / BuildAndDeploy (push) Successful in 1m47s
All checks were successful
Build and Publish / BuildAndDeploy (push) Successful in 1m47s
This commit is contained in:
@@ -94,30 +94,10 @@ func NewSyncedPool(local *GrainLocalPool, hostname string, d Discovery) (*Synced
|
||||
log.Printf("Error adding remote %s: %v", h, err)
|
||||
}
|
||||
}
|
||||
otherHosts, err := pool.Negotiate(hosts)
|
||||
if err != nil {
|
||||
log.Printf("Error negotiating: %v\n", err)
|
||||
}
|
||||
for _, h := range otherHosts {
|
||||
if h == hostname {
|
||||
continue
|
||||
}
|
||||
found := false
|
||||
for _, r := range pool.remotes {
|
||||
if r.Host == h {
|
||||
found = true
|
||||
}
|
||||
}
|
||||
if found {
|
||||
continue
|
||||
}
|
||||
err := pool.AddRemote(h)
|
||||
if err != nil {
|
||||
log.Printf("Error adding undiscovered remote %s: %v\n", h, err)
|
||||
}
|
||||
}
|
||||
|
||||
}(time.NewTicker(time.Second * 10))
|
||||
}(time.NewTicker(time.Second * 5))
|
||||
} else {
|
||||
log.Printf("No discovery, waiting for remotes to connect")
|
||||
}
|
||||
go func() {
|
||||
for {
|
||||
@@ -207,6 +187,7 @@ func NewPacketQueue(connection net.Conn) *PacketQueue {
|
||||
go func() {
|
||||
for {
|
||||
messageType, data, err := ReceivePacket(queue.connection)
|
||||
ts := time.Now()
|
||||
if err != nil {
|
||||
log.Printf("Error receiving packet: %v\n", err)
|
||||
if err == io.EOF {
|
||||
@@ -226,7 +207,7 @@ func NewPacketQueue(connection net.Conn) *PacketQueue {
|
||||
}
|
||||
queue.Packets = append(queue.Packets, PacketWithData{
|
||||
MessageType: messageType,
|
||||
Added: time.Now(),
|
||||
Added: ts,
|
||||
Data: data,
|
||||
})
|
||||
queue.mu.Unlock()
|
||||
@@ -236,7 +217,7 @@ func NewPacketQueue(connection net.Conn) *PacketQueue {
|
||||
}
|
||||
|
||||
func (p *PacketQueue) Expect(messageType uint16, timeToWait time.Duration) (*PacketWithData, error) {
|
||||
start := time.Now()
|
||||
start := time.Now().Add(-time.Millisecond)
|
||||
|
||||
for {
|
||||
if time.Since(start) > timeToWait {
|
||||
|
||||
Reference in New Issue
Block a user