Merge lp:~pedronis/ubuntu-push/connwarn into lp:ubuntu-push/automatic

Proposed by Samuele Pedroni
Status: Merged
Approved by: Samuele Pedroni
Approved revision: 127
Merged at revision: 127
Proposed branch: lp:~pedronis/ubuntu-push/connwarn
Merge into: lp:ubuntu-push/automatic
Diff against target: 807 lines (+333/-153)
10 files modified
protocol/messages.go (+32/-0)
protocol/messages_test.go (+10/-2)
protocol/state-diag-client.gv (+4/-1)
protocol/state-diag-client.svg (+77/-49)
protocol/state-diag-session.gv (+10/-0)
protocol/state-diag-session.svg (+132/-74)
server/broker/exchanges.go (+10/-13)
server/broker/exchanges_test.go (+7/-4)
server/session/session.go (+18/-6)
server/session/session_test.go (+33/-4)
To merge this branch: bzr merge lp:~pedronis/ubuntu-push/connwarn
Reviewer Review Type Date Requested Status
John Lenton (community) Approve
Review via email: mp+216082@code.launchpad.net

Commit message

support sending one way connwarn messages (meant for warning about partial functionality)

Description of the change

* support sending one way connwarn messages (meant for warning about partial functionality)
* update protocol diagrams about CONNBROKEN and CONNWARN

* also fix ping interval tracking

To post a comment you must log in.
lp:~pedronis/ubuntu-push/connwarn updated
127. By Samuele Pedroni

fix doc comment

Revision history for this message
John Lenton (chipaca) wrote :

Nice.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'protocol/messages.go'
2--- protocol/messages.go 2014-04-04 13:54:45 +0000
3+++ protocol/messages.go 2014-04-16 12:28:59 +0000
4@@ -54,6 +54,14 @@
5 Split() (done bool)
6 }
7
8+// OnewayMsg are messages that are not to be followed by a response,
9+// after sending them the session either aborts or continues.
10+type OnewayMsg interface {
11+ SplittableMsg
12+ // continue session after the message?
13+ OnewayContinue() bool
14+}
15+
16 // CONNBROKEN message, server side is breaking the connection for reason.
17 type ConnBrokenMsg struct {
18 Type string `json:"T"`
19@@ -65,11 +73,35 @@
20 return true
21 }
22
23+func (m *ConnBrokenMsg) OnewayContinue() bool {
24+ return false
25+}
26+
27 // CONNBROKEN reasons
28 const (
29 BrokenHostMismatch = "host-mismatch"
30 )
31
32+// CONNWARN message, server side is warning about partial functionality
33+// because reason.
34+type ConnWarnMsg struct {
35+ Type string `json:"T"`
36+ // reason
37+ Reason string
38+}
39+
40+func (m *ConnWarnMsg) Split() bool {
41+ return true
42+}
43+func (m *ConnWarnMsg) OnewayContinue() bool {
44+ return true
45+}
46+
47+// CONNWARN reasons
48+const (
49+ WarnUnauthorized = "unauthorized"
50+)
51+
52 // PING/PONG messages
53 type PingPongMsg struct {
54 Type string `json:"T"`
55
56=== modified file 'protocol/messages_test.go'
57--- protocol/messages_test.go 2014-04-04 13:19:10 +0000
58+++ protocol/messages_test.go 2014-04-16 12:28:59 +0000
59@@ -104,6 +104,14 @@
60 c.Check(b.splitting, Equals, 0)
61 }
62
63-func (s *messagesSuite) TestSplitConnBrokenMsg(c *C) {
64- c.Check((&ConnBrokenMsg{}).Split(), Equals, true)
65+func (s *messagesSuite) TestConnBrokenMsg(c *C) {
66+ m := &ConnBrokenMsg{}
67+ c.Check(m.Split(), Equals, true)
68+ c.Check(m.OnewayContinue(), Equals, false)
69+}
70+
71+func (s *messagesSuite) TestConnWarnMsg(c *C) {
72+ m := &ConnWarnMsg{}
73+ c.Check(m.Split(), Equals, true)
74+ c.Check(m.OnewayContinue(), Equals, true)
75 }
76
77=== modified file 'protocol/state-diag-client.gv'
78--- protocol/state-diag-client.gv 2014-01-16 20:07:13 +0000
79+++ protocol/state-diag-client.gv 2014-04-16 12:28:59 +0000
80@@ -2,7 +2,7 @@
81 label = "State diagram for client";
82 size="12,6";
83 rankdir=LR;
84- node [shape = doublecircle]; pingTimeout;
85+ node [shape = doublecircle]; pingTimeout; connBroken;
86 node [shape = circle];
87 start1 -> start2 [ label = "Write wire version" ];
88 start2 -> start3 [ label = "Write CONNECT" ];
89@@ -13,4 +13,7 @@
90 broadcast -> loop [label = "Write ACK"];
91 loop -> pingTimeout [
92 label = "Elapsed ping interval + exchange interval"];
93+ loop -> connBroken [label = "Read CONNBROKEN"];
94+ loop -> warn [label = "Read CONNWARN"];
95+ warn -> loop;
96 }
97
98=== modified file 'protocol/state-diag-client.svg'
99--- protocol/state-diag-client.svg 2014-01-16 19:37:57 +0000
100+++ protocol/state-diag-client.svg 2014-04-16 12:28:59 +0000
101@@ -4,95 +4,123 @@
102 <!-- Generated by graphviz version 2.26.3 (20100126.1600)
103 -->
104 <!-- Title: state_diagram_client Pages: 1 -->
105-<svg width="864pt" height="279pt"
106- viewBox="0.00 0.00 864.00 278.89" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
107-<g id="graph1" class="graph" transform="scale(0.683544 0.683544) rotate(0) translate(4 404)">
108+<svg width="822pt" height="432pt"
109+ viewBox="0.00 0.00 822.36 432.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
110+<g id="graph1" class="graph" transform="scale(0.650602 0.650602) rotate(0) translate(4 660)">
111 <title>state_diagram_client</title>
112-<polygon fill="white" stroke="white" points="-4,5 -4,-404 1261,-404 1261,5 -4,5"/>
113+<polygon fill="white" stroke="white" points="-4,5 -4,-660 1261,-660 1261,5 -4,5"/>
114 <text text-anchor="middle" x="628" y="-9.4" font-family="Times Roman,serif" font-size="14.00">State diagram for client</text>
115 <!-- pingTimeout -->
116 <g id="node1" class="node"><title>pingTimeout</title>
117-<ellipse fill="none" stroke="black" cx="1180" cy="-324" rx="72.1249" ry="72.1249"/>
118-<ellipse fill="none" stroke="black" cx="1180" cy="-324" rx="76.1249" ry="76.1249"/>
119-<text text-anchor="middle" x="1180" y="-320.4" font-family="Times Roman,serif" font-size="14.00">pingTimeout</text>
120+<ellipse fill="none" stroke="black" cx="1180" cy="-580" rx="72.1249" ry="72.1249"/>
121+<ellipse fill="none" stroke="black" cx="1180" cy="-580" rx="76.1249" ry="76.1249"/>
122+<text text-anchor="middle" x="1180" y="-576.4" font-family="Times Roman,serif" font-size="14.00">pingTimeout</text>
123+</g>
124+<!-- connBroken -->
125+<g id="node2" class="node"><title>connBroken</title>
126+<ellipse fill="none" stroke="black" cx="1180" cy="-413" rx="68.8251" ry="69.2965"/>
127+<ellipse fill="none" stroke="black" cx="1180" cy="-413" rx="72.7978" ry="73.2965"/>
128+<text text-anchor="middle" x="1180" y="-409.4" font-family="Times Roman,serif" font-size="14.00">connBroken</text>
129 </g>
130 <!-- start1 -->
131-<g id="node2" class="node"><title>start1</title>
132-<ellipse fill="none" stroke="black" cx="42" cy="-166" rx="41.2167" ry="41.7193"/>
133-<text text-anchor="middle" x="42" y="-162.4" font-family="Times Roman,serif" font-size="14.00">start1</text>
134+<g id="node3" class="node"><title>start1</title>
135+<ellipse fill="none" stroke="black" cx="42" cy="-231" rx="41.2167" ry="41.7193"/>
136+<text text-anchor="middle" x="42" y="-227.4" font-family="Times Roman,serif" font-size="14.00">start1</text>
137 </g>
138 <!-- start2 -->
139-<g id="node4" class="node"><title>start2</title>
140-<ellipse fill="none" stroke="black" cx="292" cy="-166" rx="41.2167" ry="41.7193"/>
141-<text text-anchor="middle" x="292" y="-162.4" font-family="Times Roman,serif" font-size="14.00">start2</text>
142+<g id="node5" class="node"><title>start2</title>
143+<ellipse fill="none" stroke="black" cx="292" cy="-231" rx="41.2167" ry="41.7193"/>
144+<text text-anchor="middle" x="292" y="-227.4" font-family="Times Roman,serif" font-size="14.00">start2</text>
145 </g>
146 <!-- start1&#45;&gt;start2 -->
147 <g id="edge2" class="edge"><title>start1&#45;&gt;start2</title>
148-<path fill="none" stroke="black" d="M83.5631,-166C126.547,-166 193.757,-166 240.181,-166"/>
149-<polygon fill="black" stroke="black" points="240.338,-169.5 250.338,-166 240.338,-162.5 240.338,-169.5"/>
150-<text text-anchor="middle" x="167" y="-171.4" font-family="Times Roman,serif" font-size="14.00">Write wire version</text>
151+<path fill="none" stroke="black" d="M83.5631,-231C126.547,-231 193.757,-231 240.181,-231"/>
152+<polygon fill="black" stroke="black" points="240.338,-234.5 250.338,-231 240.338,-227.5 240.338,-234.5"/>
153+<text text-anchor="middle" x="167" y="-236.4" font-family="Times Roman,serif" font-size="14.00">Write wire version</text>
154 </g>
155 <!-- start3 -->
156-<g id="node6" class="node"><title>start3</title>
157-<ellipse fill="none" stroke="black" cx="526" cy="-166" rx="41.2167" ry="41.7193"/>
158-<text text-anchor="middle" x="526" y="-162.4" font-family="Times Roman,serif" font-size="14.00">start3</text>
159+<g id="node7" class="node"><title>start3</title>
160+<ellipse fill="none" stroke="black" cx="526" cy="-231" rx="41.2167" ry="41.7193"/>
161+<text text-anchor="middle" x="526" y="-227.4" font-family="Times Roman,serif" font-size="14.00">start3</text>
162 </g>
163 <!-- start2&#45;&gt;start3 -->
164 <g id="edge4" class="edge"><title>start2&#45;&gt;start3</title>
165-<path fill="none" stroke="black" d="M333.565,-166C372.875,-166 431.992,-166 474.321,-166"/>
166-<polygon fill="black" stroke="black" points="474.429,-169.5 484.429,-166 474.429,-162.5 474.429,-169.5"/>
167-<text text-anchor="middle" x="409" y="-171.4" font-family="Times Roman,serif" font-size="14.00">Write CONNECT</text>
168+<path fill="none" stroke="black" d="M333.565,-231C372.875,-231 431.992,-231 474.321,-231"/>
169+<polygon fill="black" stroke="black" points="474.429,-234.5 484.429,-231 474.429,-227.5 474.429,-234.5"/>
170+<text text-anchor="middle" x="409" y="-236.4" font-family="Times Roman,serif" font-size="14.00">Write CONNECT</text>
171 </g>
172 <!-- loop -->
173-<g id="node8" class="node"><title>loop</title>
174-<ellipse fill="none" stroke="black" cx="746" cy="-166" rx="31.8198" ry="31.8198"/>
175-<text text-anchor="middle" x="746" y="-162.4" font-family="Times Roman,serif" font-size="14.00">loop</text>
176+<g id="node9" class="node"><title>loop</title>
177+<ellipse fill="none" stroke="black" cx="746" cy="-231" rx="31.8198" ry="31.8198"/>
178+<text text-anchor="middle" x="746" y="-227.4" font-family="Times Roman,serif" font-size="14.00">loop</text>
179 </g>
180 <!-- start3&#45;&gt;loop -->
181 <g id="edge6" class="edge"><title>start3&#45;&gt;loop</title>
182-<path fill="none" stroke="black" d="M567.639,-166C606.633,-166 664.616,-166 703.793,-166"/>
183-<polygon fill="black" stroke="black" points="703.818,-169.5 713.818,-166 703.818,-162.5 703.818,-169.5"/>
184-<text text-anchor="middle" x="641" y="-171.4" font-family="Times Roman,serif" font-size="14.00">Read CONNACK</text>
185+<path fill="none" stroke="black" d="M567.639,-231C606.633,-231 664.616,-231 703.793,-231"/>
186+<polygon fill="black" stroke="black" points="703.818,-234.5 713.818,-231 703.818,-227.5 703.818,-234.5"/>
187+<text text-anchor="middle" x="641" y="-236.4" font-family="Times Roman,serif" font-size="14.00">Read CONNACK</text>
188 </g>
189 <!-- loop&#45;&gt;pingTimeout -->
190 <g id="edge16" class="edge"><title>loop&#45;&gt;pingTimeout</title>
191-<path fill="none" stroke="black" d="M763.666,-192.937C772.211,-204.042 783.361,-216.128 796,-224 888.06,-281.339 1012.12,-305.973 1094,-316.443"/>
192-<polygon fill="black" stroke="black" points="1093.67,-319.928 1104.02,-317.68 1094.53,-312.981 1093.67,-319.928"/>
193-<text text-anchor="middle" x="941" y="-319.4" font-family="Times Roman,serif" font-size="14.00">Elapsed ping interval + exchange interval</text>
194+<path fill="none" stroke="black" d="M750.211,-262.971C757.458,-313.528 773.689,-408.79 796,-434 872.806,-520.784 1006.81,-556.22 1094.46,-570.528"/>
195+<polygon fill="black" stroke="black" points="1093.96,-573.992 1104.39,-572.09 1095.05,-567.078 1093.96,-573.992"/>
196+<text text-anchor="middle" x="941" y="-572.4" font-family="Times Roman,serif" font-size="14.00">Elapsed ping interval + exchange interval</text>
197+</g>
198+<!-- loop&#45;&gt;connBroken -->
199+<g id="edge18" class="edge"><title>loop&#45;&gt;connBroken</title>
200+<path fill="none" stroke="black" d="M755.1,-261.824C762.755,-282.438 775.756,-308.526 796,-324 883.382,-390.791 1012.39,-408.797 1096.33,-412.948"/>
201+<polygon fill="black" stroke="black" points="1096.19,-416.445 1106.33,-413.388 1096.5,-409.452 1096.19,-416.445"/>
202+<text text-anchor="middle" x="941" y="-417.4" font-family="Times Roman,serif" font-size="14.00">Read CONNBROKEN</text>
203 </g>
204 <!-- pong -->
205-<g id="node10" class="node"><title>pong</title>
206-<ellipse fill="none" stroke="black" cx="1180" cy="-195" rx="34.8574" ry="35.3553"/>
207-<text text-anchor="middle" x="1180" y="-191.4" font-family="Times Roman,serif" font-size="14.00">pong</text>
208+<g id="node11" class="node"><title>pong</title>
209+<ellipse fill="none" stroke="black" cx="1180" cy="-287" rx="34.8574" ry="35.3553"/>
210+<text text-anchor="middle" x="1180" y="-283.4" font-family="Times Roman,serif" font-size="14.00">pong</text>
211 </g>
212 <!-- loop&#45;&gt;pong -->
213 <g id="edge8" class="edge"><title>loop&#45;&gt;pong</title>
214-<path fill="none" stroke="black" d="M775.392,-179.044C782.046,-181.465 789.167,-183.653 796,-185 916.362,-208.722 1062.02,-203.515 1134.48,-198.706"/>
215-<polygon fill="black" stroke="black" points="1134.89,-202.186 1144.62,-198.003 1134.4,-195.203 1134.89,-202.186"/>
216-<text text-anchor="middle" x="941" y="-207.4" font-family="Times Roman,serif" font-size="14.00">Read PING</text>
217+<path fill="none" stroke="black" d="M768.467,-253.959C776.476,-260.698 786.005,-267.259 796,-271 911.696,-314.31 1060.9,-303.343 1134.62,-293.955"/>
218+<polygon fill="black" stroke="black" points="1135.49,-297.371 1144.94,-292.588 1134.57,-290.432 1135.49,-297.371"/>
219+<text text-anchor="middle" x="941" y="-307.4" font-family="Times Roman,serif" font-size="14.00">Read PING</text>
220 </g>
221 <!-- broadcast -->
222-<g id="node12" class="node"><title>broadcast</title>
223-<ellipse fill="none" stroke="black" cx="1180" cy="-84" rx="58.1882" ry="58.6899"/>
224-<text text-anchor="middle" x="1180" y="-80.4" font-family="Times Roman,serif" font-size="14.00">broadcast</text>
225+<g id="node13" class="node"><title>broadcast</title>
226+<ellipse fill="none" stroke="black" cx="1180" cy="-176" rx="58.1882" ry="58.6899"/>
227+<text text-anchor="middle" x="1180" y="-172.4" font-family="Times Roman,serif" font-size="14.00">broadcast</text>
228 </g>
229 <!-- loop&#45;&gt;broadcast -->
230 <g id="edge10" class="edge"><title>loop&#45;&gt;broadcast</title>
231-<path fill="none" stroke="black" d="M770.52,-145.1C778.217,-139.607 787.053,-134.301 796,-131 917.482,-86.1746 957.924,-122.075 1086,-103 1094.61,-101.717 1103.63,-100.165 1112.53,-98.5074"/>
232-<polygon fill="black" stroke="black" points="1113.34,-101.917 1122.5,-96.5998 1112.02,-95.0419 1113.34,-101.917"/>
233-<text text-anchor="middle" x="941" y="-136.4" font-family="Times Roman,serif" font-size="14.00">Read BROADCAST</text>
234+<path fill="none" stroke="black" d="M775.45,-218.228C782.1,-215.791 789.205,-213.528 796,-212 922.145,-183.64 957.464,-202.973 1086,-189 1094.36,-188.091 1103.12,-187.028 1111.79,-185.909"/>
235+<polygon fill="black" stroke="black" points="1112.44,-189.353 1121.9,-184.574 1111.53,-182.413 1112.44,-189.353"/>
236+<text text-anchor="middle" x="941" y="-217.4" font-family="Times Roman,serif" font-size="14.00">Read BROADCAST</text>
237+</g>
238+<!-- warn -->
239+<g id="node19" class="node"><title>warn</title>
240+<ellipse fill="none" stroke="black" cx="1180" cy="-63" rx="36.7696" ry="36.7696"/>
241+<text text-anchor="middle" x="1180" y="-59.4" font-family="Times Roman,serif" font-size="14.00">warn</text>
242+</g>
243+<!-- loop&#45;&gt;warn -->
244+<g id="edge20" class="edge"><title>loop&#45;&gt;warn</title>
245+<path fill="none" stroke="black" d="M753.357,-199.767C760.401,-177.027 773.396,-147.441 796,-131 901.425,-54.3166 958.242,-112.935 1086,-87 1101.84,-83.7841 1119.02,-79.6061 1134.3,-75.6396"/>
246+<polygon fill="black" stroke="black" points="1135.26,-79.0068 1144.04,-73.0757 1133.48,-72.2376 1135.26,-79.0068"/>
247+<text text-anchor="middle" x="941" y="-136.4" font-family="Times Roman,serif" font-size="14.00">Read CONNWARN</text>
248 </g>
249 <!-- pong&#45;&gt;loop -->
250 <g id="edge12" class="edge"><title>pong&#45;&gt;loop</title>
251-<path fill="none" stroke="black" d="M1147.19,-180.867C1129.44,-173.986 1106.92,-166.463 1086,-163 980.081,-145.465 853.051,-154.36 788.368,-160.981"/>
252-<polygon fill="black" stroke="black" points="787.736,-157.528 778.16,-162.06 788.472,-164.489 787.736,-157.528"/>
253-<text text-anchor="middle" x="941" y="-168.4" font-family="Times Roman,serif" font-size="14.00">Write PONG</text>
254+<path fill="none" stroke="black" d="M1148.22,-271.079C1130.39,-262.942 1107.48,-253.77 1086,-249 1030.54,-236.684 866.695,-232.715 788.482,-231.502"/>
255+<polygon fill="black" stroke="black" points="788.085,-227.996 778.035,-231.348 787.982,-234.995 788.085,-227.996"/>
256+<text text-anchor="middle" x="941" y="-254.4" font-family="Times Roman,serif" font-size="14.00">Write PONG</text>
257 </g>
258 <!-- broadcast&#45;&gt;loop -->
259 <g id="edge14" class="edge"><title>broadcast&#45;&gt;loop</title>
260-<path fill="none" stroke="black" d="M1123.8,-67.0114C1044.83,-46.6166 899.156,-22.0001 796,-81 778.946,-90.7538 767.135,-108.842 759.293,-125.833"/>
261-<polygon fill="black" stroke="black" points="756.044,-124.528 755.336,-135.099 762.482,-127.277 756.044,-124.528"/>
262-<text text-anchor="middle" x="941" y="-86.4" font-family="Times Roman,serif" font-size="14.00">Write ACK</text>
263+<path fill="none" stroke="black" d="M1121.7,-168.205C1028.72,-156.837 851.665,-139.849 796,-167 784,-172.853 774.037,-183.132 766.245,-193.762"/>
264+<polygon fill="black" stroke="black" points="763.182,-192.043 760.465,-202.284 768.975,-195.973 763.182,-192.043"/>
265+<text text-anchor="middle" x="941" y="-172.4" font-family="Times Roman,serif" font-size="14.00">Write ACK</text>
266+</g>
267+<!-- warn&#45;&gt;loop -->
268+<g id="edge22" class="edge"><title>warn&#45;&gt;loop</title>
269+<path fill="none" stroke="black" d="M1144.07,-53.3553C1070.4,-35.8873 900.397,-7.71825 796,-87 779.313,-99.6722 764.14,-151.763 754.991,-189.659"/>
270+<polygon fill="black" stroke="black" points="751.574,-188.904 752.686,-199.44 758.387,-190.51 751.574,-188.904"/>
271 </g>
272 </g>
273 </svg>
274
275=== modified file 'protocol/state-diag-session.gv'
276--- protocol/state-diag-session.gv 2014-01-16 20:07:13 +0000
277+++ protocol/state-diag-session.gv 2014-04-16 12:28:59 +0000
278@@ -2,6 +2,7 @@
279 label = "State diagram for session";
280 size="12,6";
281 rankdir=LR;
282+ node [shape = doublecircle]; stop;
283 node [shape = circle];
284 start1 -> start2 [ label = "Read wire version" ];
285 start2 -> start3 [ label = "Read CONNECT" ];
286@@ -17,4 +18,13 @@
287 split_broadcast -> split_ack_wait [label = "Write split BROADCAST"];
288 split_ack_wait -> split_broadcast [label = "Read ACK"];
289 split_broadcast -> loop [label = "All split msgs written"];
290+ // other
291+ loop -> conn_broken [label = "Receive connbroken request"];
292+ loop -> conn_warn [label = "Receive connwarn request"];
293+ conn_broken -> stop [label = "Write CONNBROKEN"];
294+ conn_warn -> loop [label = "Write CONNWARN"];
295+ // timeouts
296+ ack_wait -> stop [label = "Elapsed exhange timeout"];
297+ split_ack_wait -> stop [label = "Elapsed exhange timeout"];
298+ pong_wait -> stop [label = "Elapsed exhange timeout"];
299 }
300
301=== modified file 'protocol/state-diag-session.svg'
302--- protocol/state-diag-session.svg 2014-01-16 19:37:57 +0000
303+++ protocol/state-diag-session.svg 2014-04-16 12:28:59 +0000
304@@ -4,139 +4,197 @@
305 <!-- Generated by graphviz version 2.26.3 (20100126.1600)
306 -->
307 <!-- Title: state_diagram_session Pages: 1 -->
308-<svg width="864pt" height="208pt"
309- viewBox="0.00 0.00 864.00 207.94" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
310-<g id="graph1" class="graph" transform="scale(0.435923 0.435923) rotate(0) translate(4 473)">
311+<svg width="864pt" height="266pt"
312+ viewBox="0.00 0.00 864.00 265.73" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
313+<g id="graph1" class="graph" transform="scale(0.367035 0.367035) rotate(0) translate(4 720)">
314 <title>state_diagram_session</title>
315-<polygon fill="white" stroke="white" points="-4,5 -4,-473 1979,-473 1979,5 -4,5"/>
316-<text text-anchor="middle" x="987" y="-9.4" font-family="Times Roman,serif" font-size="14.00">State diagram for session</text>
317+<polygon fill="white" stroke="white" points="-4,5 -4,-720 2351,-720 2351,5 -4,5"/>
318+<text text-anchor="middle" x="1173" y="-9.4" font-family="Times Roman,serif" font-size="14.00">State diagram for session</text>
319+<!-- stop -->
320+<g id="node1" class="node"><title>stop</title>
321+<ellipse fill="none" stroke="black" cx="2309" cy="-335" rx="32.0813" ry="32.5269"/>
322+<ellipse fill="none" stroke="black" cx="2309" cy="-335" rx="36.0265" ry="36.5269"/>
323+<text text-anchor="middle" x="2309" y="-331.4" font-family="Times Roman,serif" font-size="14.00">stop</text>
324+</g>
325 <!-- start1 -->
326-<g id="node1" class="node"><title>start1</title>
327-<ellipse fill="none" stroke="black" cx="42" cy="-294" rx="41.2167" ry="41.7193"/>
328-<text text-anchor="middle" x="42" y="-290.4" font-family="Times Roman,serif" font-size="14.00">start1</text>
329+<g id="node2" class="node"><title>start1</title>
330+<ellipse fill="none" stroke="black" cx="42" cy="-395" rx="41.2167" ry="41.7193"/>
331+<text text-anchor="middle" x="42" y="-391.4" font-family="Times Roman,serif" font-size="14.00">start1</text>
332 </g>
333 <!-- start2 -->
334-<g id="node3" class="node"><title>start2</title>
335-<ellipse fill="none" stroke="black" cx="286" cy="-294" rx="41.2167" ry="41.7193"/>
336-<text text-anchor="middle" x="286" y="-290.4" font-family="Times Roman,serif" font-size="14.00">start2</text>
337+<g id="node4" class="node"><title>start2</title>
338+<ellipse fill="none" stroke="black" cx="286" cy="-395" rx="41.2167" ry="41.7193"/>
339+<text text-anchor="middle" x="286" y="-391.4" font-family="Times Roman,serif" font-size="14.00">start2</text>
340 </g>
341 <!-- start1&#45;&gt;start2 -->
342 <g id="edge2" class="edge"><title>start1&#45;&gt;start2</title>
343-<path fill="none" stroke="black" d="M83.6679,-294C125.213,-294 189.13,-294 233.981,-294"/>
344-<polygon fill="black" stroke="black" points="234.096,-297.5 244.096,-294 234.096,-290.5 234.096,-297.5"/>
345-<text text-anchor="middle" x="164" y="-299.4" font-family="Times Roman,serif" font-size="14.00">Read wire version</text>
346+<path fill="none" stroke="black" d="M83.6679,-395C125.213,-395 189.13,-395 233.981,-395"/>
347+<polygon fill="black" stroke="black" points="234.096,-398.5 244.096,-395 234.096,-391.5 234.096,-398.5"/>
348+<text text-anchor="middle" x="164" y="-400.4" font-family="Times Roman,serif" font-size="14.00">Read wire version</text>
349 </g>
350 <!-- start3 -->
351-<g id="node5" class="node"><title>start3</title>
352-<ellipse fill="none" stroke="black" cx="516" cy="-294" rx="41.2167" ry="41.7193"/>
353-<text text-anchor="middle" x="516" y="-290.4" font-family="Times Roman,serif" font-size="14.00">start3</text>
354+<g id="node6" class="node"><title>start3</title>
355+<ellipse fill="none" stroke="black" cx="537" cy="-395" rx="41.2167" ry="41.7193"/>
356+<text text-anchor="middle" x="537" y="-391.4" font-family="Times Roman,serif" font-size="14.00">start3</text>
357 </g>
358 <!-- start2&#45;&gt;start3 -->
359 <g id="edge4" class="edge"><title>start2&#45;&gt;start3</title>
360-<path fill="none" stroke="black" d="M327.651,-294C365.959,-294 422.903,-294 464.145,-294"/>
361-<polygon fill="black" stroke="black" points="464.271,-297.5 474.271,-294 464.271,-290.5 464.271,-297.5"/>
362-<text text-anchor="middle" x="401" y="-299.4" font-family="Times Roman,serif" font-size="14.00">Read CONNECT</text>
363+<path fill="none" stroke="black" d="M327.729,-395C370.886,-395 438.364,-395 484.973,-395"/>
364+<polygon fill="black" stroke="black" points="485.171,-398.5 495.171,-395 485.171,-391.5 485.171,-398.5"/>
365+<text text-anchor="middle" x="401" y="-400.4" font-family="Times Roman,serif" font-size="14.00">Read CONNECT</text>
366 </g>
367 <!-- loop -->
368-<g id="node7" class="node"><title>loop</title>
369-<ellipse fill="none" stroke="black" cx="740" cy="-294" rx="31.8198" ry="31.8198"/>
370-<text text-anchor="middle" x="740" y="-290.4" font-family="Times Roman,serif" font-size="14.00">loop</text>
371+<g id="node8" class="node"><title>loop</title>
372+<ellipse fill="none" stroke="black" cx="790" cy="-395" rx="31.8198" ry="31.8198"/>
373+<text text-anchor="middle" x="790" y="-391.4" font-family="Times Roman,serif" font-size="14.00">loop</text>
374 </g>
375 <!-- start3&#45;&gt;loop -->
376 <g id="edge6" class="edge"><title>start3&#45;&gt;loop</title>
377-<path fill="none" stroke="black" d="M557.608,-294C597.53,-294 657.517,-294 697.677,-294"/>
378-<polygon fill="black" stroke="black" points="697.687,-297.5 707.687,-294 697.687,-290.5 697.687,-297.5"/>
379-<text text-anchor="middle" x="633" y="-299.4" font-family="Times Roman,serif" font-size="14.00">Write CONNACK</text>
380+<path fill="none" stroke="black" d="M578.778,-395C625.49,-395 700.728,-395 747.665,-395"/>
381+<polygon fill="black" stroke="black" points="747.805,-398.5 757.805,-395 747.805,-391.5 747.805,-398.5"/>
382+<text text-anchor="middle" x="675" y="-400.4" font-family="Times Roman,serif" font-size="14.00">Write CONNACK</text>
383 </g>
384 <!-- ping -->
385-<g id="node9" class="node"><title>ping</title>
386-<ellipse fill="none" stroke="black" cx="1063" cy="-416" rx="32.0265" ry="32.5269"/>
387-<text text-anchor="middle" x="1063" y="-412.4" font-family="Times Roman,serif" font-size="14.00">ping</text>
388+<g id="node10" class="node"><title>ping</title>
389+<ellipse fill="none" stroke="black" cx="1135" cy="-593" rx="32.0265" ry="32.5269"/>
390+<text text-anchor="middle" x="1135" y="-589.4" font-family="Times Roman,serif" font-size="14.00">ping</text>
391 </g>
392 <!-- loop&#45;&gt;ping -->
393 <g id="edge8" class="edge"><title>loop&#45;&gt;ping</title>
394-<path fill="none" stroke="black" d="M754.564,-322.853C763.046,-336.78 775.035,-352.491 790,-362 861.597,-407.491 963.396,-415.983 1020.29,-416.829"/>
395-<polygon fill="black" stroke="black" points="1020.35,-420.33 1030.38,-416.906 1020.4,-413.33 1020.35,-420.33"/>
396-<text text-anchor="middle" x="881" y="-418.4" font-family="Times Roman,serif" font-size="14.00">Elapsed ping interval</text>
397+<path fill="none" stroke="black" d="M800.39,-425.317C809.609,-448.006 825.187,-478.237 848,-497 920.691,-556.785 1032.18,-579.907 1092.58,-588.403"/>
398+<polygon fill="black" stroke="black" points="1092.15,-591.877 1102.53,-589.734 1093.08,-584.939 1092.15,-591.877"/>
399+<text text-anchor="middle" x="946" y="-583.4" font-family="Times Roman,serif" font-size="14.00">Elapsed ping interval</text>
400 </g>
401 <!-- broadcast -->
402-<g id="node11" class="node"><title>broadcast</title>
403-<ellipse fill="none" stroke="black" cx="1063" cy="-200" rx="58.1882" ry="58.6899"/>
404-<text text-anchor="middle" x="1063" y="-196.4" font-family="Times Roman,serif" font-size="14.00">broadcast</text>
405+<g id="node12" class="node"><title>broadcast</title>
406+<ellipse fill="none" stroke="black" cx="1135" cy="-281" rx="58.1882" ry="58.6899"/>
407+<text text-anchor="middle" x="1135" y="-277.4" font-family="Times Roman,serif" font-size="14.00">broadcast</text>
408 </g>
409 <!-- loop&#45;&gt;broadcast -->
410 <g id="edge10" class="edge"><title>loop&#45;&gt;broadcast</title>
411-<path fill="none" stroke="black" d="M766.046,-274.934C773.498,-270.155 781.824,-265.421 790,-262 856.828,-234.035 938.382,-217.617 994.86,-208.779"/>
412-<polygon fill="black" stroke="black" points="995.396,-212.238 1004.75,-207.269 994.34,-205.318 995.396,-212.238"/>
413-<text text-anchor="middle" x="881" y="-267.4" font-family="Times Roman,serif" font-size="14.00">Receive broadcast request</text>
414+<path fill="none" stroke="black" d="M811.332,-370.953C821.492,-360.892 834.388,-349.946 848,-343 917.32,-307.628 1006.03,-292.395 1066.35,-285.86"/>
415+<polygon fill="black" stroke="black" points="1066.94,-289.319 1076.53,-284.811 1066.22,-282.355 1066.94,-289.319"/>
416+<text text-anchor="middle" x="946" y="-348.4" font-family="Times Roman,serif" font-size="14.00">Receive broadcast request</text>
417+</g>
418+<!-- conn_broken -->
419+<g id="node26" class="node"><title>conn_broken</title>
420+<ellipse fill="none" stroke="black" cx="1361" cy="-99" rx="73.0388" ry="73.5391"/>
421+<text text-anchor="middle" x="1361" y="-95.4" font-family="Times Roman,serif" font-size="14.00">conn_broken</text>
422+</g>
423+<!-- loop&#45;&gt;conn_broken -->
424+<g id="edge28" class="edge"><title>loop&#45;&gt;conn_broken</title>
425+<path fill="none" stroke="black" d="M793.216,-363.054C799.833,-304.219 817.014,-182.243 848,-155 967.196,-50.2026 1167.08,-63.6291 1278.91,-81.8408"/>
426+<polygon fill="black" stroke="black" points="1278.34,-85.2954 1288.79,-83.4998 1279.5,-78.392 1278.34,-85.2954"/>
427+<text text-anchor="middle" x="946" y="-160.4" font-family="Times Roman,serif" font-size="14.00">Receive connbroken request</text>
428+</g>
429+<!-- conn_warn -->
430+<g id="node28" class="node"><title>conn_warn</title>
431+<ellipse fill="none" stroke="black" cx="1135" cy="-477" rx="65.7609" ry="65.7609"/>
432+<text text-anchor="middle" x="1135" y="-473.4" font-family="Times Roman,serif" font-size="14.00">conn_warn</text>
433+</g>
434+<!-- loop&#45;&gt;conn_warn -->
435+<g id="edge30" class="edge"><title>loop&#45;&gt;conn_warn</title>
436+<path fill="none" stroke="black" d="M814.092,-416.512C823.957,-424.185 835.89,-432.126 848,-437 915.942,-464.343 999.421,-473.523 1058.8,-476.355"/>
437+<polygon fill="black" stroke="black" points="1058.71,-479.855 1068.85,-476.786 1059.01,-472.861 1058.71,-479.855"/>
438+<text text-anchor="middle" x="946" y="-480.4" font-family="Times Roman,serif" font-size="14.00">Receive connwarn request</text>
439 </g>
440 <!-- pong_wait -->
441-<g id="node13" class="node"><title>pong_wait</title>
442-<ellipse fill="none" stroke="black" cx="1526" cy="-406" rx="62.9325" ry="62.9325"/>
443-<text text-anchor="middle" x="1526" y="-402.4" font-family="Times Roman,serif" font-size="14.00">pong_wait</text>
444+<g id="node14" class="node"><title>pong_wait</title>
445+<ellipse fill="none" stroke="black" cx="537" cy="-653" rx="62.9325" ry="62.9325"/>
446+<text text-anchor="middle" x="537" y="-649.4" font-family="Times Roman,serif" font-size="14.00">pong_wait</text>
447 </g>
448 <!-- ping&#45;&gt;pong_wait -->
449 <g id="edge12" class="edge"><title>ping&#45;&gt;pong_wait</title>
450-<path fill="none" stroke="black" d="M1095.56,-415.297C1169.19,-413.707 1350.04,-409.8 1452.36,-407.591"/>
451-<polygon fill="black" stroke="black" points="1452.69,-411.084 1462.61,-407.369 1452.54,-404.086 1452.69,-411.084"/>
452-<text text-anchor="middle" x="1289" y="-418.4" font-family="Times Roman,serif" font-size="14.00">Write PING</text>
453+<path fill="none" stroke="black" d="M1103.4,-600.831C1035.81,-617.134 871.913,-654.261 732,-667 681.542,-671.594 668.481,-671.33 618,-667 615.134,-666.754 612.217,-666.46 609.275,-666.127"/>
454+<polygon fill="black" stroke="black" points="609.573,-662.637 599.214,-664.858 608.697,-669.582 609.573,-662.637"/>
455+<text text-anchor="middle" x="790" y="-670.4" font-family="Times Roman,serif" font-size="14.00">Write PING</text>
456 </g>
457 <!-- ack_wait -->
458-<g id="node15" class="node"><title>ack_wait</title>
459-<ellipse fill="none" stroke="black" cx="1526" cy="-269" rx="55.1543" ry="55.1543"/>
460-<text text-anchor="middle" x="1526" y="-265.4" font-family="Times Roman,serif" font-size="14.00">ack_wait</text>
461+<g id="node16" class="node"><title>ack_wait</title>
462+<ellipse fill="none" stroke="black" cx="1598" cy="-373" rx="55.1543" ry="55.1543"/>
463+<text text-anchor="middle" x="1598" y="-369.4" font-family="Times Roman,serif" font-size="14.00">ack_wait</text>
464 </g>
465 <!-- broadcast&#45;&gt;ack_wait -->
466 <g id="edge14" class="edge"><title>broadcast&#45;&gt;ack_wait</title>
467-<path fill="none" stroke="black" d="M1121.17,-208.669C1207.93,-221.599 1370.7,-245.856 1461.17,-259.339"/>
468-<polygon fill="black" stroke="black" points="1460.9,-262.837 1471.3,-260.849 1461.93,-255.913 1460.9,-262.837"/>
469-<text text-anchor="middle" x="1289" y="-257.4" font-family="Times Roman,serif" font-size="14.00">Write BROADCAST [fits one wire msg]</text>
470+<path fill="none" stroke="black" d="M1193.25,-288.88C1264.95,-299.067 1390.23,-318.45 1496,-343 1508.9,-345.993 1522.57,-349.664 1535.58,-353.397"/>
471+<polygon fill="black" stroke="black" points="1534.79,-356.813 1545.37,-356.254 1536.75,-350.093 1534.79,-356.813"/>
472+<text text-anchor="middle" x="1361" y="-348.4" font-family="Times Roman,serif" font-size="14.00">Write BROADCAST [fits one wire msg]</text>
473 </g>
474 <!-- split_broadcast -->
475-<g id="node17" class="node"><title>split_broadcast</title>
476-<ellipse fill="none" stroke="black" cx="1526" cy="-110" rx="84.1457" ry="84.1457"/>
477-<text text-anchor="middle" x="1526" y="-106.4" font-family="Times Roman,serif" font-size="14.00">split_broadcast</text>
478+<g id="node18" class="node"><title>split_broadcast</title>
479+<ellipse fill="none" stroke="black" cx="1598" cy="-216" rx="84.1457" ry="84.1457"/>
480+<text text-anchor="middle" x="1598" y="-212.4" font-family="Times Roman,serif" font-size="14.00">split_broadcast</text>
481 </g>
482 <!-- broadcast&#45;&gt;split_broadcast -->
483 <g id="edge16" class="edge"><title>broadcast&#45;&gt;split_broadcast</title>
484-<path fill="none" stroke="black" d="M1120.7,-188.783C1199.06,-173.553 1340.01,-146.154 1433.29,-128.021"/>
485-<polygon fill="black" stroke="black" points="1434.15,-131.421 1443.29,-126.077 1432.81,-124.549 1434.15,-131.421"/>
486-<text text-anchor="middle" x="1289" y="-185.4" font-family="Times Roman,serif" font-size="14.00">BROADCAST does not fit one wire msg</text>
487+<path fill="none" stroke="black" d="M1193.17,-272.834C1271.44,-261.846 1411.56,-242.174 1504.66,-229.104"/>
488+<polygon fill="black" stroke="black" points="1505.23,-232.558 1514.65,-227.702 1504.26,-225.626 1505.23,-232.558"/>
489+<text text-anchor="middle" x="1361" y="-272.4" font-family="Times Roman,serif" font-size="14.00">BROADCAST does not fit one wire msg</text>
490+</g>
491+<!-- pong_wait&#45;&gt;stop -->
492+<g id="edge40" class="edge"><title>pong_wait&#45;&gt;stop</title>
493+<path fill="none" stroke="black" d="M600.164,-653C651.344,-653 725.322,-653 790,-653 790,-653 790,-653 1972,-653 2131.11,-653 2245.53,-463.168 2289.33,-376.844"/>
494+<polygon fill="black" stroke="black" points="2292.5,-378.343 2293.84,-367.834 2286.24,-375.212 2292.5,-378.343"/>
495+<text text-anchor="middle" x="1361" y="-658.4" font-family="Times Roman,serif" font-size="14.00">Elapsed exhange timeout</text>
496 </g>
497 <!-- pong_wait&#45;&gt;loop -->
498 <g id="edge18" class="edge"><title>pong_wait&#45;&gt;loop</title>
499-<path fill="none" stroke="black" d="M1463.29,-398.59C1336,-383.27 1038.34,-346.004 790,-304 787.177,-303.523 784.269,-303.006 781.343,-302.468"/>
500-<polygon fill="black" stroke="black" points="781.898,-299.011 771.42,-300.582 780.59,-305.888 781.898,-299.011"/>
501-<text text-anchor="middle" x="1063" y="-359.4" font-family="Times Roman,serif" font-size="14.00">Read PONG</text>
502+<path fill="none" stroke="black" d="M581.359,-607.765C632.774,-555.333 716.085,-470.376 760.273,-425.314"/>
503+<polygon fill="black" stroke="black" points="762.774,-427.763 767.277,-418.172 757.776,-422.862 762.774,-427.763"/>
504+<text text-anchor="middle" x="675" y="-574.4" font-family="Times Roman,serif" font-size="14.00">Read PONG</text>
505+</g>
506+<!-- ack_wait&#45;&gt;stop -->
507+<g id="edge36" class="edge"><title>ack_wait&#45;&gt;stop</title>
508+<path fill="none" stroke="black" d="M1653.02,-372.757C1765.96,-371.776 2032.03,-366.986 2254,-344 2256.89,-343.701 2259.85,-343.348 2262.84,-342.959"/>
509+<polygon fill="black" stroke="black" points="2263.58,-346.389 2272.99,-341.517 2262.59,-339.459 2263.58,-346.389"/>
510+<text text-anchor="middle" x="1972" y="-373.4" font-family="Times Roman,serif" font-size="14.00">Elapsed exhange timeout</text>
511 </g>
512 <!-- ack_wait&#45;&gt;loop -->
513 <g id="edge20" class="edge"><title>ack_wait&#45;&gt;loop</title>
514-<path fill="none" stroke="black" d="M1470.96,-271.898C1455.75,-272.644 1439.24,-273.404 1424,-274 1181.02,-283.507 889.323,-290.597 782.144,-293.057"/>
515-<polygon fill="black" stroke="black" points="781.977,-289.56 772.059,-293.288 782.136,-296.558 781.977,-289.56"/>
516-<text text-anchor="middle" x="1063" y="-292.4" font-family="Times Roman,serif" font-size="14.00">Read ACK</text>
517+<path fill="none" stroke="black" d="M1542.83,-374.081C1445.66,-375.995 1237.64,-380.146 1062,-384 966.886,-386.087 942.947,-382.989 848,-389 842.829,-389.327 837.406,-389.764 832.04,-390.252"/>
518+<polygon fill="black" stroke="black" points="831.485,-386.79 821.871,-391.242 832.163,-393.757 831.485,-386.79"/>
519+<text text-anchor="middle" x="1135" y="-389.4" font-family="Times Roman,serif" font-size="14.00">Read ACK</text>
520 </g>
521 <!-- split_broadcast&#45;&gt;loop -->
522 <g id="edge26" class="edge"><title>split_broadcast&#45;&gt;loop</title>
523-<path fill="none" stroke="black" d="M1442.56,-99.9981C1336.06,-89.6718 1146.8,-79.5577 990,-115 894.383,-136.612 862.41,-141.921 790,-208 775.817,-220.943 764.522,-238.865 756.283,-254.999"/>
524-<polygon fill="black" stroke="black" points="753.014,-253.718 751.785,-264.241 759.308,-256.781 753.014,-253.718"/>
525-<text text-anchor="middle" x="1063" y="-120.4" font-family="Times Roman,serif" font-size="14.00">All split msgs written</text>
526+<path fill="none" stroke="black" d="M1515.33,-201.109C1409.22,-184.681 1219.98,-164.458 1062,-196 960.985,-216.168 924.079,-215.554 848,-285 827.351,-303.849 812.751,-331.776 803.364,-354.774"/>
527+<polygon fill="black" stroke="black" points="800.027,-353.699 799.658,-364.287 806.549,-356.24 800.027,-353.699"/>
528+<text text-anchor="middle" x="1135" y="-201.4" font-family="Times Roman,serif" font-size="14.00">All split msgs written</text>
529 </g>
530 <!-- split_ack_wait -->
531-<g id="node21" class="node"><title>split_ack_wait</title>
532-<ellipse fill="none" stroke="black" cx="1893" cy="-110" rx="80.1095" ry="80.6102"/>
533-<text text-anchor="middle" x="1893" y="-106.4" font-family="Times Roman,serif" font-size="14.00">split_ack_wait</text>
534+<g id="node22" class="node"><title>split_ack_wait</title>
535+<ellipse fill="none" stroke="black" cx="1972" cy="-257" rx="80.1095" ry="80.6102"/>
536+<text text-anchor="middle" x="1972" y="-253.4" font-family="Times Roman,serif" font-size="14.00">split_ack_wait</text>
537 </g>
538 <!-- split_broadcast&#45;&gt;split_ack_wait -->
539 <g id="edge22" class="edge"><title>split_broadcast&#45;&gt;split_ack_wait</title>
540-<path fill="none" stroke="black" d="M1610.2,-110C1667.61,-110 1743.59,-110 1802.33,-110"/>
541-<polygon fill="black" stroke="black" points="1802.35,-113.5 1812.35,-110 1802.34,-106.5 1802.35,-113.5"/>
542-<text text-anchor="middle" x="1711" y="-115.4" font-family="Times Roman,serif" font-size="14.00">Write split BROADCAST</text>
543+<path fill="none" stroke="black" d="M1680.55,-232.126C1687.12,-233.18 1693.66,-234.156 1700,-235 1760.22,-243.022 1828.36,-248.528 1881.38,-252.025"/>
544+<polygon fill="black" stroke="black" points="1881.23,-255.523 1891.43,-252.676 1881.68,-248.537 1881.23,-255.523"/>
545+<text text-anchor="middle" x="1783" y="-256.4" font-family="Times Roman,serif" font-size="14.00">Write split BROADCAST</text>
546+</g>
547+<!-- split_ack_wait&#45;&gt;stop -->
548+<g id="edge38" class="edge"><title>split_ack_wait&#45;&gt;stop</title>
549+<path fill="none" stroke="black" d="M2050.59,-275.189C2116.55,-290.456 2208.51,-311.74 2263.08,-324.372"/>
550+<polygon fill="black" stroke="black" points="2262.62,-327.857 2273.15,-326.702 2264.2,-321.037 2262.62,-327.857"/>
551+<text text-anchor="middle" x="2166" y="-327.4" font-family="Times Roman,serif" font-size="14.00">Elapsed exhange timeout</text>
552 </g>
553 <!-- split_ack_wait&#45;&gt;split_broadcast -->
554 <g id="edge24" class="edge"><title>split_ack_wait&#45;&gt;split_broadcast</title>
555-<path fill="none" stroke="black" d="M1814.64,-90.9448C1807.69,-89.7544 1800.74,-88.7397 1794,-88 1720.66,-79.9496 1701.36,-80.1783 1628,-88 1624.71,-88.3505 1621.38,-88.7628 1618.01,-89.2264"/>
556-<polygon fill="black" stroke="black" points="1617.23,-85.8043 1607.87,-90.7602 1618.28,-92.7256 1617.23,-85.8043"/>
557-<text text-anchor="middle" x="1711" y="-93.4" font-family="Times Roman,serif" font-size="14.00">Read ACK</text>
558+<path fill="none" stroke="black" d="M1899.33,-222.493C1888.37,-218.573 1877.04,-215.2 1866,-213 1808.89,-201.617 1743.56,-202.081 1691.71,-205.529"/>
559+<polygon fill="black" stroke="black" points="1691.25,-202.053 1681.52,-206.256 1691.74,-209.035 1691.25,-202.053"/>
560+<text text-anchor="middle" x="1783" y="-218.4" font-family="Times Roman,serif" font-size="14.00">Read ACK</text>
561+</g>
562+<!-- conn_broken&#45;&gt;stop -->
563+<g id="edge32" class="edge"><title>conn_broken&#45;&gt;stop</title>
564+<path fill="none" stroke="black" d="M1434.61,-95.8477C1564.45,-92.5456 1841.16,-95.6985 2060,-168 2154.32,-199.163 2175.34,-218.326 2254,-279 2262.17,-285.305 2270.33,-292.782 2277.75,-300.185"/>
565+<polygon fill="black" stroke="black" points="2275.42,-302.808 2284.91,-307.517 2280.43,-297.917 2275.42,-302.808"/>
566+<text text-anchor="middle" x="1783" y="-127.4" font-family="Times Roman,serif" font-size="14.00">Write CONNBROKEN</text>
567+</g>
568+<!-- conn_warn&#45;&gt;loop -->
569+<g id="edge34" class="edge"><title>conn_warn&#45;&gt;loop</title>
570+<path fill="none" stroke="black" d="M1083.63,-435.301C1071.29,-427.246 1057.71,-419.822 1044,-415 972.758,-389.933 883.562,-389.406 832.05,-391.836"/>
571+<polygon fill="black" stroke="black" points="831.758,-388.346 821.959,-392.373 832.131,-395.337 831.758,-388.346"/>
572+<text text-anchor="middle" x="946" y="-420.4" font-family="Times Roman,serif" font-size="14.00">Write CONNWARN</text>
573 </g>
574 </g>
575 </svg>
576
577=== modified file 'server/broker/exchanges.go'
578--- server/broker/exchanges.go 2014-04-04 13:19:10 +0000
579+++ server/broker/exchanges.go 2014-04-16 12:28:59 +0000
580@@ -119,23 +119,20 @@
581 return nil
582 }
583
584-// ConnBrokenExchange breaks a session giving a reason.
585-type ConnBrokenExchange struct {
586- Reason string
587+// ConnMetaExchange allows to send a CONNBROKEN or CONNWARN message.
588+type ConnMetaExchange struct {
589+ Msg protocol.OnewayMsg
590 }
591
592 // check interface already here
593-var _ Exchange = (*ConnBrokenExchange)(nil)
594+var _ Exchange = (*ConnMetaExchange)(nil)
595
596-// Prepare session for a CONNBROKEN.
597-func (cbe *ConnBrokenExchange) Prepare(sess BrokerSession) (outMessage protocol.SplittableMsg, inMessage interface{}, err error) {
598- scratchArea := sess.ExchangeScratchArea()
599- scratchArea.connBrokenMsg.Type = "connbroken"
600- scratchArea.connBrokenMsg.Reason = cbe.Reason
601- return &scratchArea.connBrokenMsg, nil, nil
602+// Prepare session for a CONNBROKEN/WARN.
603+func (cbe *ConnMetaExchange) Prepare(sess BrokerSession) (outMessage protocol.SplittableMsg, inMessage interface{}, err error) {
604+ return cbe.Msg, nil, nil
605 }
606
607-// CONNBROKEN isn't acked
608-func (cbe *ConnBrokenExchange) Acked(sess BrokerSession, done bool) error {
609- panic("Acked should not get invoked on ConnBrokenExchange")
610+// CONNBROKEN/WARN aren't acked.
611+func (cbe *ConnMetaExchange) Acked(sess BrokerSession, done bool) error {
612+ panic("Acked should not get invoked on ConnMetaExchange")
613 }
614
615=== modified file 'server/broker/exchanges_test.go'
616--- server/broker/exchanges_test.go 2014-04-04 13:19:10 +0000
617+++ server/broker/exchanges_test.go 2014-04-16 12:28:59 +0000
618@@ -24,6 +24,7 @@
619
620 . "launchpad.net/gocheck"
621
622+ "launchpad.net/ubuntu-push/protocol"
623 "launchpad.net/ubuntu-push/server/broker"
624 "launchpad.net/ubuntu-push/server/broker/testing"
625 "launchpad.net/ubuntu-push/server/store"
626@@ -249,16 +250,18 @@
627 c.Check(sess.LevelsMap[store.SystemInternalChannelId], Equals, int64(5))
628 }
629
630-func (s *exchangesSuite) TestConnBrokenExchange(c *C) {
631+func (s *exchangesSuite) TestConnMetaExchange(c *C) {
632 sess := &testing.TestBrokerSession{}
633- cbe := &broker.ConnBrokenExchange{"REASON"}
634+ var msg protocol.OnewayMsg = &protocol.ConnWarnMsg{"connwarn", "REASON"}
635+ cbe := &broker.ConnMetaExchange{msg}
636 outMsg, inMsg, err := cbe.Prepare(sess)
637 c.Assert(err, IsNil)
638+ c.Check(msg, Equals, outMsg)
639 c.Check(inMsg, IsNil) // no answer is expected
640 // check
641 marshalled, err := json.Marshal(outMsg)
642 c.Assert(err, IsNil)
643- c.Check(string(marshalled), Equals, `{"T":"connbroken","Reason":"REASON"}`)
644+ c.Check(string(marshalled), Equals, `{"T":"connwarn","Reason":"REASON"}`)
645
646- c.Check(func() { cbe.Acked(nil, true) }, PanicMatches, "Acked should not get invoked on ConnBrokenExchange")
647+ c.Check(func() { cbe.Acked(nil, true) }, PanicMatches, "Acked should not get invoked on ConnMetaExchange")
648 }
649
650=== modified file 'server/session/session.go'
651--- server/session/session.go 2014-04-11 08:47:18 +0000
652+++ server/session/session.go 2014-04-16 12:28:59 +0000
653@@ -18,6 +18,7 @@
654 package session
655
656 import (
657+ "errors"
658 "net"
659 "time"
660
661@@ -55,6 +56,8 @@
662 return brkr.Register(&connMsg)
663 }
664
665+var errOneway = errors.New("oneway")
666+
667 // exchange writes outMsg message, reads answer in inMsg
668 func exchange(proto protocol.Protocol, outMsg, inMsg interface{}, exchangeTimeout time.Duration) error {
669 proto.SetDeadline(time.Now().Add(exchangeTimeout))
670@@ -62,7 +65,10 @@
671 if err != nil {
672 return err
673 }
674- if inMsg == nil { // no answer expected, breaking connection
675+ if inMsg == nil { // no answer expected
676+ if outMsg.(protocol.OnewayMsg).OnewayContinue() {
677+ return errOneway
678+ }
679 return &broker.ErrAbort{"session broken for reason"}
680 }
681 err = proto.ReadMessage(inMsg)
682@@ -78,6 +84,10 @@
683 exchangeTimeout := cfg.ExchangeTimeout()
684 pingTimer := time.NewTimer(pingInterval)
685 intervalStart := time.Now()
686+ pingTimerReset := func() {
687+ pingTimer.Reset(pingInterval)
688+ intervalStart = time.Now()
689+ }
690 ch := sess.SessionChannel()
691 Loop:
692 for {
693@@ -93,7 +103,7 @@
694 if pongMsg.Type != "pong" {
695 return &broker.ErrAbort{"expected PONG message"}
696 }
697- pingTimer.Reset(pingInterval)
698+ pingTimerReset()
699 case exchg, ok := <-ch:
700 pingTimer.Stop()
701 if !ok {
702@@ -101,8 +111,7 @@
703 }
704 outMsg, inMsg, err := exchg.Prepare(sess)
705 if err == broker.ErrNop { // nothing to do
706- pingTimer.Reset(pingInterval)
707- intervalStart = time.Now()
708+ pingTimerReset()
709 continue Loop
710 }
711 if err != nil {
712@@ -111,12 +120,15 @@
713 for {
714 done := outMsg.Split()
715 err = exchange(proto, outMsg, inMsg, exchangeTimeout)
716+ if err == errOneway {
717+ pingTimerReset()
718+ continue Loop
719+ }
720 if err != nil {
721 return err
722 }
723 if done {
724- pingTimer.Reset(pingInterval)
725- intervalStart = time.Now()
726+ pingTimerReset()
727 }
728 err = exchg.Acked(sess, done)
729 if err != nil {
730
731=== modified file 'server/session/session_test.go'
732--- server/session/session_test.go 2014-04-11 08:47:18 +0000
733+++ server/session/session_test.go 2014-04-16 12:28:59 +0000
734@@ -222,14 +222,14 @@
735 }
736
737 func (s *sessionSuite) TestSessionLoop(c *C) {
738- nopTrack := NewTracker(s.testlog)
739+ track := &testTracker{NewTracker(s.testlog), make(chan interface{}, 2)}
740 errCh := make(chan error, 1)
741 up := make(chan interface{}, 5)
742 down := make(chan interface{}, 5)
743 tp := &testProtocol{up, down}
744 sess := &testing.TestBrokerSession{}
745 go func() {
746- errCh <- sessionLoop(tp, sess, cfg5msPingInterval2msExchangeTout, nopTrack)
747+ errCh <- sessionLoop(tp, sess, cfg5msPingInterval2msExchangeTout, track)
748 }()
749 c.Check(takeNext(down), Equals, "deadline 2ms")
750 c.Check(takeNext(down), DeepEquals, protocol.PingPongMsg{Type: "ping"})
751@@ -241,6 +241,9 @@
752 up <- io.ErrUnexpectedEOF
753 err := <-errCh
754 c.Check(err, Equals, io.ErrUnexpectedEOF)
755+ c.Check(track.interval, HasLen, 2)
756+ c.Check((<-track.interval).(time.Duration) <= 8*time.Millisecond, Equals, true)
757+ c.Check((<-track.interval).(time.Duration) <= 8*time.Millisecond, Equals, true)
758 }
759
760 func (s *sessionSuite) TestSessionLoopWriteError(c *C) {
761@@ -477,18 +480,44 @@
762 down := make(chan interface{}, 5)
763 tp := &testProtocol{up, down}
764 exchanges := make(chan broker.Exchange, 1)
765- exchanges <- &broker.ConnBrokenExchange{"REASON"}
766+ msg := &protocol.ConnBrokenMsg{"connbroken", "BREASON"}
767+ exchanges <- &broker.ConnMetaExchange{msg}
768 sess := &testing.TestBrokerSession{Exchanges: exchanges}
769 go func() {
770 errCh <- sessionLoop(tp, sess, cfg5msPingInterval2msExchangeTout, nopTrack)
771 }()
772 c.Check(takeNext(down), Equals, "deadline 2ms")
773- c.Check(takeNext(down), DeepEquals, protocol.ConnBrokenMsg{"connbroken", "REASON"})
774+ c.Check(takeNext(down), DeepEquals, protocol.ConnBrokenMsg{"connbroken", "BREASON"})
775 up <- nil // no write error
776 err := <-errCh
777 c.Check(err, DeepEquals, &broker.ErrAbort{"session broken for reason"})
778 }
779
780+func (s *sessionSuite) TestSessionLoopConnWarnExchange(c *C) {
781+ nopTrack := NewTracker(s.testlog)
782+ errCh := make(chan error, 1)
783+ up := make(chan interface{}, 5)
784+ down := make(chan interface{}, 5)
785+ tp := &testProtocol{up, down}
786+ exchanges := make(chan broker.Exchange, 1)
787+ msg := &protocol.ConnWarnMsg{"connwarn", "WREASON"}
788+ exchanges <- &broker.ConnMetaExchange{msg}
789+ sess := &testing.TestBrokerSession{Exchanges: exchanges}
790+ go func() {
791+ errCh <- sessionLoop(tp, sess, cfg5msPingInterval2msExchangeTout, nopTrack)
792+ }()
793+ c.Check(takeNext(down), Equals, "deadline 2ms")
794+ c.Check(takeNext(down), DeepEquals, protocol.ConnWarnMsg{"connwarn", "WREASON"})
795+ up <- nil // no write error
796+ // session continues
797+ c.Check(takeNext(down), Equals, "deadline 2ms")
798+ c.Check(takeNext(down), DeepEquals, protocol.PingPongMsg{Type: "ping"})
799+ up <- nil // no write error
800+ up <- io.EOF
801+ err := <-errCh
802+ c.Check(err, Equals, io.EOF)
803+}
804+
805 type testTracker struct {
806 SessionTracker
807 interval chan interface{}

Subscribers

People subscribed via source and target branches