File tree 2 files changed +10
-12
lines changed
2 files changed +10
-12
lines changed Original file line number Diff line number Diff line change @@ -259,12 +259,6 @@ func (c *Connection) handleConnectionError(err error) {
259
259
260
260
// close everything else we close normally
261
261
c .close ()
262
-
263
- if c .Opts .ConnectionClosedHandlers != nil && len (c .Opts .ConnectionClosedHandlers ) > 0 {
264
- for _ , handler := range c .Opts .ConnectionClosedHandlers {
265
- go handler (c )
266
- }
267
- }
268
262
}
269
263
270
264
func (c * Connection ) close () error {
@@ -280,6 +274,12 @@ func (c *Connection) close() error {
280
274
}
281
275
}
282
276
277
+ if c .Opts .ConnectionClosedHandlers != nil && len (c .Opts .ConnectionClosedHandlers ) > 0 {
278
+ for _ , handler := range c .Opts .ConnectionClosedHandlers {
279
+ go handler (c )
280
+ }
281
+ }
282
+
283
283
return nil
284
284
}
285
285
Original file line number Diff line number Diff line change @@ -161,6 +161,10 @@ func (p *Pool) handleClosedConnection(closedConn *Connection) {
161
161
p .mu .Lock ()
162
162
defer p .mu .Unlock ()
163
163
164
+ if p .isClosed {
165
+ return
166
+ }
167
+
164
168
var connIndex = - 1
165
169
for i , conn := range p .connections {
166
170
if conn == closedConn {
@@ -181,12 +185,6 @@ func (p *Pool) handleClosedConnection(closedConn *Connection) {
181
185
p .connections [connsNum - 1 ] = nil // Erase last element
182
186
p .connections = p .connections [:connsNum - 1 ] // Truncate slice.
183
187
184
- // if pool was closed, don't start recreate goroutine
185
- // should we return earlier and keep connection in the pool as it will be closed anyway?
186
- if p .isClosed {
187
- return
188
- }
189
-
190
188
// initiate goroutine to reconnect to closedConn.Addr
191
189
p .wg .Add (1 )
192
190
go p .recreateConnection (closedConn )
You can’t perform that action at this time.
0 commit comments