Merge lp:~noise/ubuntu-push/flapping-fix-more-tweaks into lp:ubuntu-push/automatic

Proposed by Bret Barker
Status: Merged
Merged at revision: 357
Proposed branch: lp:~noise/ubuntu-push/flapping-fix-more-tweaks
Merge into: lp:ubuntu-push/automatic
Prerequisite: lp:~chipaca/ubuntu-push/flapping-fixes
Diff against target: 131 lines (+36/-9)
4 files modified
bus/connectivity/connectivity.go (+15/-9)
client/client.go (+1/-0)
client/session/session.go (+2/-0)
ubuntu-push-client.go (+18/-0)
To merge this branch: bzr merge lp:~noise/ubuntu-push/flapping-fix-more-tweaks
Reviewer Review Type Date Requested Status
John Lenton (community) Approve
Review via email: mp+247222@code.launchpad.net

Commit message

add SIGQUIT handler to spit out stack dumps; logging tweaks.

To post a comment you must log in.
Revision history for this message
John Lenton (chipaca) :
review: Approve
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :

Attempt to merge into lp:ubuntu-push/automatic failed due to conflicts:

text conflict in bus/connectivity/connectivity.go

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bus/connectivity/connectivity.go'
--- bus/connectivity/connectivity.go 2015-01-21 21:31:07 +0000
+++ bus/connectivity/connectivity.go 2015-01-21 21:31:07 +0000
@@ -120,44 +120,50 @@
120 case <-cs.networkConCh:120 case <-cs.networkConCh:
121 cs.webgetCh = nil121 cs.webgetCh = nil
122 cs.timer.Reset(stabilizingTimeout)122 cs.timer.Reset(stabilizingTimeout)
123 log.Debugf("PrimaryConnection changed. Assuming disconnect.")
124 if cs.lastSent == true {123 if cs.lastSent == true {
124 log.Debugf("connectivity: PrimaryConnection changed. lastSent: %v, sending 'disconnected'.", cs.lastSent)
125 cs.lastSent = false125 cs.lastSent = false
126 break Loop126 break Loop
127 } else {
128 log.Debugf("connectivity: PrimaryConnection changed. lastSent: %v, Ignoring.", cs.lastSent)
127 }129 }
128130
129 case v, ok := <-cs.networkStateCh:131 case v, ok := <-cs.networkStateCh:
132 // Handle only disconnecting here, connecting handled under the timer below
130 if !ok {133 if !ok {
131 // tear it all down and start over134 // tear it all down and start over
132 return false, errors.New("got not-OK from StateChanged watch")135 return false, errors.New("got not-OK from StateChanged watch")
133 }136 }
134 cs.webgetCh = nil137 cs.webgetCh = nil
135 if v != networkmanager.Connecting && cs.currentState != v {138 lastState := cs.currentState
136 cs.currentState = v139 cs.currentState = v
140 // ignore Connecting (followed immediately by "Connected Global") and repeats
141 if v != networkmanager.Connecting && lastState != v {
137 cs.timer.Reset(stabilizingTimeout)142 cs.timer.Reset(stabilizingTimeout)
138 log.Debugf("State changed to %s. Assuming disconnect.", v)
139 if cs.lastSent == true {143 if cs.lastSent == true {
140 log.Debugf("sending 'disconnected'.")144 log.Debugf("connectivity: %s -> %s. lastSent: %v, sending 'disconnected'", lastState, v, cs.lastSent)
141 cs.lastSent = false145 cs.lastSent = false
142 break Loop146 break Loop
147 } else {
148 log.Debugf("connectivity: %s -> %s. lastSent: %v, Ignoring.", lastState, v, cs.lastSent)
143 }149 }
144 } else {150 } else {
145 log.Debugf("got State of %s, current is %s, ignoring.", v, cs.currentState)151 log.Debugf("connectivity: %s -> %s. lastSent: %v, Ignoring.", lastState, v, cs.lastSent)
146 }152 }
147153
148 case <-cs.timer.C:154 case <-cs.timer.C:
149 if cs.currentState == networkmanager.ConnectedGlobal {155 if cs.currentState == networkmanager.ConnectedGlobal {
150 log.Debugf("may be connected; checking...")156 log.Debugf("connectivity: timer signal, state: ConnectedGlobal, checking...")
151 cs.webgetCh = make(chan bool)157 cs.webgetCh = make(chan bool)
152 go cs.webget(cs.webgetCh)158 go cs.webget(cs.webgetCh)
153 }159 }
154160
155 case connected := <-cs.webgetCh:161 case connected := <-cs.webgetCh:
156 cs.timer.Reset(recheckTimeout)162 cs.timer.Reset(recheckTimeout)
157 log.Debugf("connection check says: %t", connected)163 log.Debugf("connectivity: connection check says: %t", connected)
158 cs.webgetCh = nil164 cs.webgetCh = nil
159 if connected && cs.lastSent == false {165 if connected && cs.lastSent == false {
160 log.Debugf("sending 'connected'.")166 log.Debugf("connectivity: connection check ok, lastSent: %v, sending 'connected'.", cs.lastSent)
161 cs.lastSent = true167 cs.lastSent = true
162 break Loop168 break Loop
163 }169 }
164170
=== modified file 'client/client.go'
--- client/client.go 2015-01-21 21:31:07 +0000
+++ client/client.go 2015-01-21 21:31:07 +0000
@@ -376,6 +376,7 @@
376376
377// handleConnState deals with connectivity events377// handleConnState deals with connectivity events
378func (client *PushClient) handleConnState(hasConnectivity bool) {378func (client *PushClient) handleConnState(hasConnectivity bool) {
379 client.log.Debugf("handleConnState: %v", hasConnectivity)
379 if client.hasConnectivity == hasConnectivity {380 if client.hasConnectivity == hasConnectivity {
380 // nothing to do!381 // nothing to do!
381 return382 return
382383
=== modified file 'client/session/session.go'
--- client/session/session.go 2015-01-21 21:31:07 +0000
+++ client/session/session.go 2015-01-21 21:31:07 +0000
@@ -234,6 +234,7 @@
234}234}
235235
236func (sess *ClientSession) setState(state ClientSessionState) {236func (sess *ClientSession) setState(state ClientSessionState) {
237 sess.Log.Debugf("session.setState: %s -> %s", ClientSessionState(atomic.LoadUint32(sess.stateP)), state)
237 atomic.StoreUint32(sess.stateP, uint32(state))238 atomic.StoreUint32(sess.stateP, uint32(state))
238}239}
239240
@@ -385,6 +386,7 @@
385 sess.Log.Debugf("session autoredialer skipping retry: retrier has been set to nil.")386 sess.Log.Debugf("session autoredialer skipping retry: retrier has been set to nil.")
386 return387 return
387 }388 }
389 sess.Log.Debugf("session autoredialier launching Redial goroutine")
388 doneCh <- retrier.Redial()390 doneCh <- retrier.Redial()
389 }()391 }()
390}392}
391393
=== modified file 'ubuntu-push-client.go'
--- ubuntu-push-client.go 2014-05-08 22:29:26 +0000
+++ ubuntu-push-client.go 2015-01-21 21:31:07 +0000
@@ -18,13 +18,31 @@
1818
19import (19import (
20 "log"20 "log"
21 "os"
22 "os/signal"
23 "runtime"
24 "syscall"
2125
22 "launchpad.net/go-xdg/v0"26 "launchpad.net/go-xdg/v0"
2327
24 "launchpad.net/ubuntu-push/client"28 "launchpad.net/ubuntu-push/client"
25)29)
2630
31func installSigQuitHandler() {
32 go func() {
33 sigs := make(chan os.Signal, 1)
34 signal.Notify(sigs, syscall.SIGQUIT)
35 buf := make([]byte, 1<<20)
36 for {
37 <-sigs
38 runtime.Stack(buf, true)
39 log.Printf("=== received SIGQUIT ===\n*** goroutine dump...\n%s\n*** end\n", buf)
40 }
41 }()
42}
43
27func main() {44func main() {
45 installSigQuitHandler()
28 cfgFname, err := xdg.Config.Find("ubuntu-push-client/config.json")46 cfgFname, err := xdg.Config.Find("ubuntu-push-client/config.json")
29 if err != nil {47 if err != nil {
30 log.Fatalf("unable to find a configuration file: %v", err)48 log.Fatalf("unable to find a configuration file: %v", err)

Subscribers

People subscribed via source and target branches