Skip to content

fix(p2p): guard conn.Close on dial error and close Exit_Event on shutdown#10

Closed
moralpriest wants to merge 4 commits into
DEROFDN:community-devfrom
moralpriest:fix/p2p-reliability
Closed

fix(p2p): guard conn.Close on dial error and close Exit_Event on shutdown#10
moralpriest wants to merge 4 commits into
DEROFDN:community-devfrom
moralpriest:fix/p2p-reliability

Conversation

@moralpriest

Copy link
Copy Markdown

Summary

Two small reliability fixes in the P2P controller:

  1. Nil-guard conn.Close() after failed KCP dial

    • connect_with_endpoint called conn.Close() unconditionally after kcp.DialWithOptions returned an error.
    • conn can be nil on error, causing a nil-pointer panic.
    • Added a nil check before closing.
  2. Restore close(Exit_Event) in P2P_Shutdown

    • The shutdown signal channel was created but never closed (commented out).
    • Background goroutines (ping loop, chunk cleanup, sync engine, time check, ban cleanup) were left hanging until process death.
    • Uncommenting close(Exit_Event) allows them to exit cleanly.

Testing

  • go build ./p2p/... and go test ./p2p/... pass.
  • Manual: start derod, connect to peers, then exit — daemon shuts down without hanging.

Files changed

  • p2p/controller.go

@8lecramm 8lecramm self-assigned this May 2, 2026

@8lecramm 8lecramm left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merged commit 0f32a79.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants