8000 simplify · coder/coder@17ddb8e · GitHub
[go: up one dir, main page]

Skip to content

Commit 17ddb8e

Browse files
committed
simplify
1 parent a77ceac commit 17ddb8e

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

agent/agent.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,8 @@ func (a *agent) reportConnectionsLoop(ctx context.Context, aAPI proto.DRPCAgentC
752752
break
753753
}
754754
payload := a.reportConnections[0]
755+
// Release lock while we send the payload, this is safe
756+
// since we only append to the slice.
755757
a.reportConnectionsMu.Unlock()
756758

757759
logger := a.logger.With(slog.F("payload", payload))
@@ -763,14 +765,10 @@ func (a *agent) reportConnectionsLoop(ctx context.Context, aAPI proto.DRPCAgentC
763765

764766
logger.Debug(ctx, "successfully reported connection")
765767

768+
// Remove the payload we sent.
766769
a.reportConnectionsMu.Lock()
767770
a.reportConnections = a.reportConnections[1:]
768-
count := len(a.reportConnections)
769771
a.reportConnectionsMu.Unlock()
770-
771-
if count == 0 {
772-
break
773-
}
774772
}
775773
}
776774
}

0 commit comments

Comments
 (0)
0