export_test.go 586 B

123456789101112131415161718192021222324252627282930313233
  1. package mgo
  2. import (
  3. "time"
  4. )
  5. func HackPingDelay(newDelay time.Duration) (restore func()) {
  6. globalMutex.Lock()
  7. defer globalMutex.Unlock()
  8. oldDelay := pingDelay
  9. restore = func() {
  10. globalMutex.Lock()
  11. pingDelay = oldDelay
  12. globalMutex.Unlock()
  13. }
  14. pingDelay = newDelay
  15. return
  16. }
  17. func HackSyncSocketTimeout(newTimeout time.Duration) (restore func()) {
  18. globalMutex.Lock()
  19. defer globalMutex.Unlock()
  20. oldTimeout := syncSocketTimeout
  21. restore = func() {
  22. globalMutex.Lock()
  23. syncSocketTimeout = oldTimeout
  24. globalMutex.Unlock()
  25. }
  26. syncSocketTimeout = newTimeout
  27. return
  28. }