remove locking/atomic from contactRetry as its single threaded
continuous-integration/drone/pr Build is failing Details

This commit is contained in:
Dan Ballard 2022-12-03 09:50:31 -08:00
parent 726fe28498
commit 2a877ff408
2 changed files with 6 additions and 7 deletions

View File

@ -9,6 +9,9 @@ import (
"time"
)
// Todo: Move to protocol/connections
// This Plugin is now required and it makes more sense to run more integrated in engine
const tickTimeSec = 30
const tickTime = tickTimeSec * time.Second
@ -121,7 +124,7 @@ func NewConnectionRetry(bus event.Manager, onion string) Plugin {
// maxTorCircuitsPending a function to throttle access to tor network during start up
func (cr *contactRetry) maxTorCircuitsPending() int {
timeSinceStart := time.Now().Sub(cr.networkUpTime)
timeSinceStart := time.Since(cr.networkUpTime)
if timeSinceStart < 30*time.Second {
return 4
} else if timeSinceStart < 4*time.Minute {
@ -241,10 +244,6 @@ func (cr *contactRetry) run() {
}
}
func ticksToSec(ticks int) int {
return ticks * tickTimeSec
}
func (cr *contactRetry) requeueReady() {
if !cr.networkUp {
return
@ -264,7 +263,7 @@ func (cr *contactRetry) requeueReady() {
p := v.(*contact)
if p.state == connections.DISCONNECTED && !p.queued {
timeout := time.Duration((math.Pow(2, float64(p.failedCount)))*float64(adjustedBaseTimeout /*baseTimeoutSec*/)) * time.Second
if time.Now().Sub(p.lastAttempt) > timeout {
if time.Since(p.lastAttempt) > timeout {
retryable = append(retryable, p)
}
}

View File

@ -1403,7 +1403,7 @@ func (cp *cwtchPeer) eventHandler() {
var cid int
if err != nil {
// if it's a newly authenticated connection with no conversation storage, init
cid, err = cp.NewContactConversation(handle, model.DefaultP2PAccessControl(), false)
cid, _ = cp.NewContactConversation(handle, model.DefaultP2PAccessControl(), false)
} else {
cid = ci.ID
}