~pedronis/ubuntu-push/acceptanceclient-send-build-num

« back to all changes in this revision

Viewing changes to poller/poller.go

  • Committer: Tarmac
  • Author(s): Bret Barker
  • Date: 2015-03-30 20:44:06 UTC
  • mfrom: (386.1.3 busy-sleep-hack)
  • Revision ID: tarmac-20150330204406-nejw3do0sk1uua0a
[r=pedronis] ref #1435109, add a hacky busy sleep loop to workaround go's sleep not accounting for suspended time

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
        NetworkWait        time.Duration
49
49
        PolldWait          time.Duration
50
50
        DoneWait           time.Duration
 
51
        BusyWait           time.Duration
51
52
}
52
53
 
53
54
type Poller interface {
111
112
        p.powerd = powerd.New(powerdEndp, p.log)
112
113
        p.polld = polld.New(polldEndp, p.log)
113
114
 
 
115
        // busy sleep loop to workaround go's timer/sleep
 
116
        // not accounting for time when the system is suspended
 
117
        // see https://bugs.launchpad.net/ubuntu/+source/ubuntu-push/+bug/1435109
 
118
        if p.times.BusyWait > 0 {
 
119
                p.log.Debugf("starting busy loop with %s interval", p.times.BusyWait)
 
120
                go func() {
 
121
                        for {
 
122
                                time.Sleep(p.times.BusyWait)
 
123
                        }
 
124
                }()
 
125
        } else {
 
126
                p.log.Debugf("skipping busy loop")
 
127
        }
114
128
        return nil
115
129
}
116
130
 
178
192
                return lockCookie
179
193
        }
180
194
        p.log.Debugf("got wakelock cookie of %s, checking conn state", lockCookie)
181
 
        // XXX killed as part of bug #1435109 troubleshooting, remove cfg if remains unused
182
 
        // time.Sleep(p.times.SessionStateSettle)
 
195
        time.Sleep(p.times.SessionStateSettle)
183
196
        for i := 0; i < 20; i++ {
184
197
                if p.IsConnected() {
185
198
                        p.log.Debugf("iter %02d: connected", i)