fix dials removal

This commit is contained in:
Steven Polley 2023-02-26 23:08:36 -07:00
parent 7d94b0e9c2
commit 5d5e28ad94
1 changed files with 7 additions and 7 deletions

View File

@ -36,19 +36,19 @@ func connPoolWatchdog(serverAddress string, maxPoolSize int, scene *core.Node) {
for {
removed := 0
// 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
log.Printf("closing bad idle connection and removing from pool - %s", dial.Connection.LocalAddr().String())
dial.Connection.Close()
removeCompleted := scene.Remove(dial.Mesh)
log.Printf("removed: %v", removeCompleted)
dials = append(dials[:i-removed], dials[i-removed+1:]...)
removed++
scene.Remove(dial.Mesh)
continue
}
dials[i] = dial
i++
}
dials = dials[:i]
// fill any empty slots in the pool with fresh connections
for poolSize := len(dials); poolSize < maxPoolSize; poolSize++ {