@@ -83,6 +83,21 @@ func (c *haCoordinator) Node(id uuid.UUID) *agpl.Node {
83
83
// with the specified ID.
84
84
func (c * haCoordinator ) ServeClient (conn net.Conn , id uuid.UUID , agent uuid.UUID ) error {
85
85
c .mutex .Lock ()
86
+ connectionSockets , ok := c .agentToConnectionSockets [agent ]
87
+ if ! ok {
88
+ connectionSockets = map [uuid.UUID ]* agpl.TrackedConn {}
89
+ c .agentToConnectionSockets [agent ] = connectionSockets
90
+ }
91
+
92
+ now := time .Now ().Unix ()
93
+ // Insert this connection into a map so the agent
94
+ // can publish node updates.
95
+ connectionSockets [id ] = & agpl.TrackedConn {
96
+ Conn : conn ,
97
+ Start : now ,
98
+ LastWrite : now ,
99
+ }
100
+
86
101
// When a new connection is requested, we update it with the latest
87
102
// node of the agent. This allows the connection to establish.
88
103
node , ok := c .nodes [agent ]
@@ -103,23 +118,6 @@ func (c *haCoordinator) ServeClient(conn net.Conn, id uuid.UUID, agent uuid.UUID
103
118
}
104
119
}
105
120
106
- c .mutex .Lock ()
107
- connectionSockets , ok := c .agentToConnectionSockets [agent ]
108
- if ! ok {
109
- connectionSockets = map [uuid.UUID ]* agpl.TrackedConn {}
110
- c .agentToConnectionSockets [agent ] = connectionSockets
111
- }
112
-
113
- now := time .Now ().Unix ()
114
- // Insert this connection into a map so the agent
115
- // can publish node updates.
116
- connectionSockets [id ] = & agpl.TrackedConn {
117
- Conn : conn ,
118
- Start : now ,
119
- LastWrite : now ,
120
- }
121
- c .mutex .Unlock ()
122
-
123
121
defer func () {
124
122
c .mutex .Lock ()
125
123
defer c .mutex .Unlock ()
0 commit comments