You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
586 B
33 lines
586 B
package mgo
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
func HackPingDelay(newDelay time.Duration) (restore func()) {
|
|
globalMutex.Lock()
|
|
defer globalMutex.Unlock()
|
|
|
|
oldDelay := pingDelay
|
|
restore = func() {
|
|
globalMutex.Lock()
|
|
pingDelay = oldDelay
|
|
globalMutex.Unlock()
|
|
}
|
|
pingDelay = newDelay
|
|
return
|
|
}
|
|
|
|
func HackSyncSocketTimeout(newTimeout time.Duration) (restore func()) {
|
|
globalMutex.Lock()
|
|
defer globalMutex.Unlock()
|
|
|
|
oldTimeout := syncSocketTimeout
|
|
restore = func() {
|
|
globalMutex.Lock()
|
|
syncSocketTimeout = oldTimeout
|
|
globalMutex.Unlock()
|
|
}
|
|
syncSocketTimeout = newTimeout
|
|
return
|
|
}
|
|
|