fix dials removal
This commit is contained in:
parent
7d94b0e9c2
commit
5d5e28ad94
@ -36,19 +36,19 @@ func connPoolWatchdog(serverAddress string, maxPoolSize int, scene *core.Node) {
|
|||||||
|
|
||||||
for {
|
for {
|
||||||
|
|
||||||
removed := 0
|
|
||||||
// Check status of existing open connections in pool
|
// Check status of existing open connections in pool
|
||||||
for i, dial := range dials {
|
i := 0 // output index
|
||||||
|
for _, dial := range dials {
|
||||||
if !isConnUp(dial.Connection) { // TBD: this should be moved to check before first write to the socket file descriptor instead of polling here
|
if !isConnUp(dial.Connection) { // TBD: this should be moved to check before first write to the socket file descriptor instead of polling here
|
||||||
log.Printf("closing bad idle connection and removing from pool - %s", dial.Connection.LocalAddr().String())
|
log.Printf("closing bad idle connection and removing from pool - %s", dial.Connection.LocalAddr().String())
|
||||||
dial.Connection.Close()
|
dial.Connection.Close()
|
||||||
removeCompleted := scene.Remove(dial.Mesh)
|
scene.Remove(dial.Mesh)
|
||||||
log.Printf("removed: %v", removeCompleted)
|
continue
|
||||||
|
|
||||||
dials = append(dials[:i-removed], dials[i-removed+1:]...)
|
|
||||||
removed++
|
|
||||||
}
|
}
|
||||||
|
dials[i] = dial
|
||||||
|
i++
|
||||||
}
|
}
|
||||||
|
dials = dials[:i]
|
||||||
|
|
||||||
// fill any empty slots in the pool with fresh connections
|
// fill any empty slots in the pool with fresh connections
|
||||||
for poolSize := len(dials); poolSize < maxPoolSize; poolSize++ {
|
for poolSize := len(dials); poolSize < maxPoolSize; poolSize++ {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user