What changed, and why it matters
This commit fixes a minor logging issue in LND's peer connection code. Previously, the software would always print a debug message saying it was waiting for a peer to finish starting up, even when that wasn't true. The change makes the log message appear only in the actual waiting case. There is no security impact.
No security action required. Treat as routine code quality/logging fix.
Security signals we found
No strong security signals were identified.
Evidence from the diff
In peer/brontide.go’s Disconnect method, the code previously logged ‘Peer hasn’t finished starting up yet, waiting on startReady signal before closing connection’ before checking whether p.startReady was already closed. The patch restructures the select so it first performs a non-blocking check of p.startReady; only if the channel is still open (startup incomplete) does it emit the debug log and then block waiting. This is a cosmetic/logic correctness fix with no functional behavior change beyond log output.
Changed components
peer/brontide.goBrontide.DisconnectInspect captured patch +15 / −5
diff --git a/peer/brontide.go b/peer/brontide.go
index 8d02ca6..c8093ac 100644
--- a/peer/brontide.go
+++ b/peer/brontide.go
@@ -1641,13 +1641,23 @@ func (p *Brontide) Disconnect(reason error) {
// started, otherwise we will skip reading it as this chan won't be
// closed, hence blocks forever.
if atomic.LoadInt32(&p.started) == 1 {
- p.log.Debugf("Peer hasn't finished starting up yet, waiting " +
- "on startReady signal before closing connection")
-
+ // First check if startup has already completed (non-blocking).
select {
case <-p.startReady:
- case <-p.cg.Done():
- return
+ // Startup already completed, no need to wait.
+
+ default:
+ // Still starting up, need to wait.
+ p.log.Debugf("Peer hasn't finished starting up yet, " +
+ "waiting on startReady signal before " +
+ "closing connection")
+
+ select {
+ case <-p.startReady:
+
+ case <-p.cg.Done():
+ return
+ }
}
}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.