File tree Expand file tree Collapse file tree 2 files changed +10
-12
lines changed
Expand file tree Collapse file tree 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) {
259259
260260 // close everything else we close normally
261261 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- }
268262}
269263
270264func (c * Connection ) close () error {
@@ -280,6 +274,12 @@ func (c *Connection) close() error {
280274 }
281275 }
282276
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+
283283 return nil
284284}
285285
Original file line number Diff line number Diff line change @@ -161,6 +161,10 @@ func (p *Pool) handleClosedConnection(closedConn *Connection) {
161161 p .mu .Lock ()
162162 defer p .mu .Unlock ()
163163
164+ if p .isClosed {
165+ return
166+ }
167+
164168 var connIndex = - 1
165169 for i , conn := range p .connections {
166170 if conn == closedConn {
@@ -181,12 +185,6 @@ func (p *Pool) handleClosedConnection(closedConn *Connection) {
181185 p .connections [connsNum - 1 ] = nil // Erase last element
182186 p .connections = p .connections [:connsNum - 1 ] // Truncate slice.
183187
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-
190188 // initiate goroutine to reconnect to closedConn.Addr
191189 p .wg .Add (1 )
192190 go p .recreateConnection (closedConn )
You can’t perform that action at this time.
0 commit comments