MCPcopy
hub / github.com/redis/go-redis / ClearRelaxedTimeout

Method ClearRelaxedTimeout

internal/pool/conn.go:482–493  ·  view source on GitHub ↗

ClearRelaxedTimeout removes relaxed timeouts, returning to normal timeout behavior. Uses atomic operations for lock-free access.

()

Source from the content-addressed store, hash-verified

480// ClearRelaxedTimeout removes relaxed timeouts, returning to normal timeout behavior.
481// Uses atomic operations for lock-free access.
482func (cn *Conn) ClearRelaxedTimeout() {
483 // Atomically decrement counter and check if we should clear
484 newCount := cn.relaxedCounter.Add(-1)
485 deadlineNs := cn.relaxedDeadlineNs.Load()
486 if newCount <= 0 && (deadlineNs == 0 || time.Now().UnixNano() >= deadlineNs) {
487 // Use atomic load to get current value for CAS to avoid stale value race
488 current := cn.relaxedCounter.Load()
489 if current <= 0 && cn.relaxedCounter.CompareAndSwap(current, 0) {
490 cn.clearRelaxedTimeout()
491 }
492 }
493}
494
495func (cn *Conn) clearRelaxedTimeout() {
496 cn.relaxedReadTimeoutNs.Store(0)

Callers 5

handleMigratedMethod · 0.80
handleFailedOverMethod · 0.80
handleSMigratedMethod · 0.80

Calls 3

clearRelaxedTimeoutMethod · 0.95
AddMethod · 0.65
LoadMethod · 0.45