Skip to content

Conversation

@0pcom
Copy link
Owner

@0pcom 0pcom commented Jul 13, 2023

Fixes #

Changes:

How to test this PR:

mrpalide and others added 30 commits August 12, 2025 07:02
* update skycoin & other vendor deps

* fix dmsgweb

* update test workflow

* update release workflow

* make format
…exing-session

Fix/data race on multiplexing session
* update skycoin & other vendor deps

* Improve signal handling for graceful shutdown on Ctrl+C

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.

* Fix data race in SessionCommon Close() and Ping() methods

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

* update skywire & skycoin vendor deps
* update skycoin & other vendor deps

* implement flags for detailed version info from runtime/debug

* Fix race condition in dmsghttp discovery validation

Add retry logic with exponential backoff when validating discovery server reachability via DMSG. This fixes the issue where some dmsg servers would fail with EOF errors immediately after session initialization.

The race condition occurred because the Ready() signal indicated the dmsg session was established, but the session was still initializing (accepting streams). HTTP requests made immediately after Ready() would fail with EOF.

Changes:
- Add 5 retry attempts with 200ms, 400ms, 600ms, 800ms backoff delays (total 2s)
- Log retry attempts at debug level for troubleshooting
- Import time package for sleep functionality

This allows all dmsg servers sufficient time to complete session initialization before declaring the connection invalid.

* Add synthetic discovery entry support for dialing discovery server

Enable regular dmsg clients to dial the discovery server even though it doesn't register itself in discovery. The discovery server uses a direct client and isn't listed in its own database.

Solution for dmsghttp mode: Implement a caching discovery client wrapper that intercepts Entry() requests for the discovery server's public key and returns a synthetic entry with all known dmsg servers as delegated servers.

Solution for -Z (HTTP) mode: Use a direct client with pre-populated entries for all dmsg servers, the discovery server, and the local client. This avoids the chicken-and-egg problem of needing dmsg transport to query discovery before having a dmsg client.

Changes:
- Add StartDmsgWithSyntheticDiscovery() for dmsghttp mode
- Add StartDmsgWithDirectClient() for -Z HTTP mode
- Implement cachingDiscClient wrapper for dmsghttp mode
- Direct client includes synthetic entries for discovery server and local client

This allows commands like 'dmsg curl -Z dmsg://discovery-pk:80/health' to work.
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.

7 participants