Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: close connection on any return from azure-vnet-telemetry #2711

Merged
merged 5 commits into from
Apr 29, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 21 additions & 19 deletions telemetry/telemetrybuffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,27 @@ func (tb *TelemetryBuffer) StartServer() error {
tb.connections = append(tb.connections, conn)
tb.mutex.Unlock()
go func() {
defer func() {
var index int
var value net.Conn
var found bool

tb.mutex.Lock()
defer tb.mutex.Unlock()

for index, value = range tb.connections {
if value == conn {
conn.Close()
found = true
break
}
}

if found {
tb.connections = remove(tb.connections, index)
}
}()

for {
reportStr, err := read(conn)
if err == nil {
Expand Down Expand Up @@ -145,25 +166,6 @@ func (tb *TelemetryBuffer) StartServer() error {
}
}
} else {
var index int
var value net.Conn
var found bool

tb.mutex.Lock()
defer tb.mutex.Unlock()

for index, value = range tb.connections {
if value == conn {
conn.Close()
found = true
break
}
}

if found {
tb.connections = remove(tb.connections, index)
}

return
}
}
Expand Down
Loading