~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/gopkg.in/mgo.v2/export_test.go

  • Committer: Nicholas Skaggs
  • Date: 2016-10-24 20:56:05 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20161024205605-z8lta0uvuhtxwzwl
Initi with beta15

Show diffs side-by-side

added added

removed removed

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