10000 chore(vpn): send ping results over tunnel by ethanndickson · Pull Request #18200 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

chore(vpn): send ping results over tunnel #18200

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

Merged
merged 13 commits into from
Jun 6, 2025
Prev Previous commit
Next Next commit
lock for conn read
  • Loading branch information
ethanndickson committed Jun 4, 2025
commit 91f80096c0a3e29a53b5e5ae57f3ba46ffc6f12d
11 changes: 8 additions & 3 deletions vpn/tunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,8 +563,8 @@ func (u *updater) stop() error {
return nil
}
err := u.conn.Close()
u.conn = nil
u.cancel()
u.conn = nil
return err
}

Expand Down Expand Up @@ -630,6 +630,13 @@ func (u *updater) recordLatency() {
u.logger.Warn(u.ctx, "failed to ping agent", slog.F("agent_id", agentID), slog.Error(err))
return
}

u.mu.Lock()
defer u.mu.Unlock()
if u.conn == nil {
u.logger.Debug(u.ctx, "ignoring ping result as connection is closed", slog.F("agent_id", agentID))
return
}
node := u.conn.Node()
derpMap := u.conn.DERPMap()
derpLatencies := tailnet.ExtractDERPLatency(node, derpMap)
Expand All @@ -640,8 +647,6 @@ func (u *updater) recordLatency() {
} else {
u.logger.Debug(u.ctx, "preferred DERP not found in DERP latency map", slog.F("preferred_derp", preferredDerp))
}
u.mu.Lock()
defer u.mu.Unlock()
if agent, ok := u.agents[agentID]; ok {
agent.lastPing = &lastPing{
pingDur: pingDur,
Expand Down
Loading
0