Merge lp:~noise/ubuntu-push/busy-sleep-hack into lp:ubuntu-push/automatic

Proposed by Bret Barker
Status: Merged
Approved by: Bret Barker
Approved revision: 389
Merged at revision: 387
Proposed branch: lp:~noise/ubuntu-push/busy-sleep-hack
Merge into: lp:ubuntu-push/automatic
Diff against target: 85 lines (+20/-3)
4 files modified
client/client.go (+2/-0)
client/client_test.go (+1/-0)
debian/config.json (+2/-1)
poller/poller.go (+15/-2)
To merge this branch: bzr merge lp:~noise/ubuntu-push/busy-sleep-hack
Reviewer Review Type Date Requested Status
Samuele Pedroni Approve
Review via email: mp+254634@code.launchpad.net

Commit message

ref #1435109, add a hacky busy sleep loop to workaround go's sleep not accounting for suspended time

To post a comment you must log in.
388. By Bret Barker

remove debug line

389. By Bret Barker

add config for poll_busy_wait, 0s to disable

Revision history for this message
Samuele Pedroni (pedronis) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'client/client.go'
2--- client/client.go 2015-03-17 10:43:50 +0000
3+++ client/client.go 2015-03-30 19:22:06 +0000
4@@ -79,6 +79,7 @@
5 PollNetworkWait config.ConfigTimeDuration `json:"poll_net_wait"`
6 PollPolldWait config.ConfigTimeDuration `json:"poll_polld_wait"`
7 PollDoneWait config.ConfigTimeDuration `json:"poll_done_wait"`
8+ PollBusyWait config.ConfigTimeDuration `json:"poll_busy_wait"`
9 }
10
11 // PushService is the interface we use of service.PushService.
12@@ -246,6 +247,7 @@
13 NetworkWait: client.config.PollNetworkWait.TimeDuration(),
14 PolldWait: client.config.PollPolldWait.TimeDuration(),
15 DoneWait: client.config.PollDoneWait.TimeDuration(),
16+ BusyWait: client.config.PollBusyWait.TimeDuration(),
17 },
18 Log: client.log,
19 SessionStateGetter: client.session,
20
21=== modified file 'client/client_test.go'
22--- client/client_test.go 2015-03-17 10:51:55 +0000
23+++ client/client_test.go 2015-03-30 19:22:06 +0000
24@@ -185,6 +185,7 @@
25 "poll_net_wait": "1m",
26 "poll_polld_wait": "3m",
27 "poll_done_wait": "5s",
28+ "poll_busy_wait": "0s",
29 }
30 for k, v := range overrides {
31 cfgMap[k] = v
32
33=== modified file 'debian/config.json'
34--- debian/config.json 2015-01-26 21:00:27 +0000
35+++ debian/config.json 2015-03-30 19:22:06 +0000
36@@ -19,5 +19,6 @@
37 "poll_settle": "20ms",
38 "poll_net_wait": "1m",
39 "poll_polld_wait": "3m",
40- "poll_done_wait": "5s"
41+ "poll_done_wait": "5s",
42+ "poll_busy_wait": "1s"
43 }
44
45=== modified file 'poller/poller.go'
46--- poller/poller.go 2015-03-26 13:48:19 +0000
47+++ poller/poller.go 2015-03-30 19:22:06 +0000
48@@ -48,6 +48,7 @@
49 NetworkWait time.Duration
50 PolldWait time.Duration
51 DoneWait time.Duration
52+ BusyWait time.Duration
53 }
54
55 type Poller interface {
56@@ -111,6 +112,19 @@
57 p.powerd = powerd.New(powerdEndp, p.log)
58 p.polld = polld.New(polldEndp, p.log)
59
60+ // busy sleep loop to workaround go's timer/sleep
61+ // not accounting for time when the system is suspended
62+ // see https://bugs.launchpad.net/ubuntu/+source/ubuntu-push/+bug/1435109
63+ if p.times.BusyWait > 0 {
64+ p.log.Debugf("starting busy loop with %s interval", p.times.BusyWait)
65+ go func() {
66+ for {
67+ time.Sleep(p.times.BusyWait)
68+ }
69+ }()
70+ } else {
71+ p.log.Debugf("skipping busy loop")
72+ }
73 return nil
74 }
75
76@@ -178,8 +192,7 @@
77 return lockCookie
78 }
79 p.log.Debugf("got wakelock cookie of %s, checking conn state", lockCookie)
80- // XXX killed as part of bug #1435109 troubleshooting, remove cfg if remains unused
81- // time.Sleep(p.times.SessionStateSettle)
82+ time.Sleep(p.times.SessionStateSettle)
83 for i := 0; i < 20; i++ {
84 if p.IsConnected() {
85 p.log.Debugf("iter %02d: connected", i)

Subscribers

People subscribed via source and target branches