File: export_test.go

package info (click to toggle)
golang-gopkg-mgo.v2 2016.08.01-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch-backports
  • size: 1,952 kB
  • sloc: ansic: 300; sh: 207; makefile: 7
file content (33 lines) | stat: -rw-r--r-- 586 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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
}