Skip to content

Conversation

@0pcom
Copy link
Collaborator

@0pcom 0pcom commented Oct 26, 2025

Fixes # #318

@0pcom 0pcom force-pushed the fix/improve-signal-handling branch from 67c8ff1 to f2471ee Compare October 26, 2025 15:34
0pcom added 2 commits October 26, 2025 10:50
Address issues where DMSG client utilities would not respond to Ctrl+C:

- Use signal-aware context for dmsgC.Serve() instead of context.Background() in internal/cli, pkg/direct, and dmsgpty-host
- Add context cancellation check in dmsg-socks5 accept loop to properly exit on signal
- Implement graceful HTTP server shutdown with 5-second timeout in dmsghttp
- Ensure dmsgC.Close() is called via defer in dmsgpty-host for proper cleanup
- Add WaitGroup wait in direct client stop function for clean goroutine shutdown
- Document temporary kill.go workaround for verification testing

These changes ensure client utilities properly respond to interrupt signals without requiring multiple Ctrl+C presses.
Protect concurrent access to sm.yamux and sm.smux fields with sm.mutx lock to prevent data races when Close() or Ping() are called while session is being initialized.

The race occurred when:
- handleSession() writes to dSes.sm.yamux (server.go:242) while holding the lock
- Close() reads sc.sm.yamux (session_common.go:187-188) without holding the lock
- A goroutine can call Close() concurrently during session setup

Changes:
- Add sm.mutx.Lock() protection in Close() method
- Add sm.mutx.RLock() protection in Ping() method for consistency
@0pcom 0pcom force-pushed the fix/improve-signal-handling branch from 56637bf to 1ec064b Compare October 26, 2025 15:50
@0pcom 0pcom merged commit c545b0e into skycoin:develop Oct 26, 2025
3 checks passed
@0pcom 0pcom deleted the fix/improve-signal-handling branch October 26, 2025 16:17
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.

1 participant