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

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

Commit message

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

Description of the change

This is lp:~noise/ubuntu-push/flapping-fix-more-tweaks with a conflict resolved.

To post a comment you must log in.
Revision history for this message
John Lenton (chipaca) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bus/connectivity/connectivity.go'
2--- bus/connectivity/connectivity.go 2015-01-22 09:54:10 +0000
3+++ bus/connectivity/connectivity.go 2015-01-22 11:12:24 +0000
4@@ -120,44 +120,51 @@
5 case <-cs.networkConCh:
6 cs.webgetCh = nil
7 cs.timer.Reset(stabilizingTimeout)
8- log.Debugf("PrimaryConnection changed. Assuming disconnect.")
9 if cs.lastSent == true {
10+ log.Debugf("connectivity: PrimaryConnection changed. lastSent: %v, sending 'disconnected'.", cs.lastSent)
11 cs.lastSent = false
12 break Loop
13+ } else {
14+ log.Debugf("connectivity: PrimaryConnection changed. lastSent: %v, Ignoring.", cs.lastSent)
15 }
16
17 case v, ok := <-cs.networkStateCh:
18+ // Handle only disconnecting here, connecting handled under the timer below
19 if !ok {
20 // tear it all down and start over
21 return false, errors.New("got not-OK from StateChanged watch")
22 }
23 cs.webgetCh = nil
24- if v != networkmanager.Connecting && cs.currentState != v {
25- cs.currentState = v
26+ lastState := cs.currentState
27+ cs.currentState = v
28+ // ignore Connecting (followed immediately by "Connected Global") and repeats
29+ if v != networkmanager.Connecting && lastState != v {
30 cs.timer.Reset(stabilizingTimeout)
31 log.Debugf("state changed to %s. Assuming disconnect.", v)
32 if cs.lastSent == true {
33- log.Debugf("sending 'disconnected'.")
34+ log.Debugf("connectivity: %s -> %s. lastSent: %v, sending 'disconnected'", lastState, v, cs.lastSent)
35 cs.lastSent = false
36 break Loop
37+ } else {
38+ log.Debugf("connectivity: %s -> %s. lastSent: %v, Ignoring.", lastState, v, cs.lastSent)
39 }
40 } else {
41- log.Debugf("got State of %s, current is %s, ignoring.", v, cs.currentState)
42+ log.Debugf("connectivity: %s -> %s. lastSent: %v, Ignoring.", lastState, v, cs.lastSent)
43 }
44
45 case <-cs.timer.C:
46 if cs.currentState == networkmanager.ConnectedGlobal {
47- log.Debugf("may be connected; checking...")
48+ log.Debugf("connectivity: timer signal, state: ConnectedGlobal, checking...")
49 cs.webgetCh = make(chan bool)
50 go cs.webget(cs.webgetCh)
51 }
52
53 case connected := <-cs.webgetCh:
54 cs.timer.Reset(recheckTimeout)
55- log.Debugf("connection check says: %t", connected)
56+ log.Debugf("connectivity: connection check says: %t", connected)
57 cs.webgetCh = nil
58 if connected && cs.lastSent == false {
59- log.Debugf("sending 'connected'.")
60+ log.Debugf("connectivity: connection check ok, lastSent: %v, sending 'connected'.", cs.lastSent)
61 cs.lastSent = true
62 break Loop
63 }
64
65=== modified file 'client/client.go'
66--- client/client.go 2015-01-22 09:54:10 +0000
67+++ client/client.go 2015-01-22 11:12:24 +0000
68@@ -376,6 +376,7 @@
69
70 // handleConnState deals with connectivity events
71 func (client *PushClient) handleConnState(hasConnectivity bool) {
72+ client.log.Debugf("handleConnState: %v", hasConnectivity)
73 if client.hasConnectivity == hasConnectivity {
74 // nothing to do!
75 return
76
77=== modified file 'client/session/session.go'
78--- client/session/session.go 2015-01-22 10:30:42 +0000
79+++ client/session/session.go 2015-01-22 11:12:24 +0000
80@@ -235,6 +235,7 @@
81 }
82
83 func (sess *ClientSession) setState(state ClientSessionState) {
84+ sess.Log.Debugf("session.setState: %s -> %s", ClientSessionState(atomic.LoadUint32(sess.stateP)), state)
85 atomic.StoreUint32(sess.stateP, uint32(state))
86 }
87
88@@ -392,6 +393,7 @@
89 sess.Log.Debugf("session autoredialer skipping retry: retrier has been set to nil.")
90 return
91 }
92+ sess.Log.Debugf("session autoredialier launching Redial goroutine")
93 doneCh <- retrier.Redial()
94 }()
95 }
96
97=== modified file 'ubuntu-push-client.go'
98--- ubuntu-push-client.go 2014-05-08 22:29:26 +0000
99+++ ubuntu-push-client.go 2015-01-22 11:12:24 +0000
100@@ -18,13 +18,31 @@
101
102 import (
103 "log"
104+ "os"
105+ "os/signal"
106+ "runtime"
107+ "syscall"
108
109 "launchpad.net/go-xdg/v0"
110
111 "launchpad.net/ubuntu-push/client"
112 )
113
114+func installSigQuitHandler() {
115+ go func() {
116+ sigs := make(chan os.Signal, 1)
117+ signal.Notify(sigs, syscall.SIGQUIT)
118+ buf := make([]byte, 1<<20)
119+ for {
120+ <-sigs
121+ runtime.Stack(buf, true)
122+ log.Printf("=== received SIGQUIT ===\n*** goroutine dump...\n%s\n*** end\n", buf)
123+ }
124+ }()
125+}
126+
127 func main() {
128+ installSigQuitHandler()
129 cfgFname, err := xdg.Config.Find("ubuntu-push-client/config.json")
130 if err != nil {
131 log.Fatalf("unable to find a configuration file: %v", err)

Subscribers

People subscribed via source and target branches