Decentralized social media network — no central server, user-owned data
Find a file
Scott Reimers 8c40e0da48 Fix: dedup concurrent outgoing connects to the same peer
Multiple code paths could each fire an outgoing connect to the same
peer simultaneously with no coordination: the existing
connections.contains_key() check under a lock, drop lock, connect
pattern leaves a window where another path passes its own check and
spawns a parallel attempt. Auto-reconnect, rebalance-slots, and the
relay-introduction target-side handler were the three identified races
(rank 1–3 in the pre-release audit). Observable as multiple
near-simultaneous "Auto-connected to peer [hex]" / "Target-side hole
punch succeeded to [hex]" log lines for the same peer.

Fix: add `pending_connects: Arc<std::sync::Mutex<HashSet<NodeId>>>` to
ConnectionManager plus a `PendingConnectGuard` RAII type. Entry to each
outgoing-connect path now acquires a guard via `try_begin_connect(peer)`
under the CM lock; the guard inserts the NodeId into the set and the
Drop impl removes it. Concurrent callers for the same peer see the
NodeId already in `pending_connects` (or already in the `connections` /
`sessions` maps) and return None, so they skip their attempt.

Scope:
- Only gates outgoing duplicates to the SAME peer. Different peers
  connect independently. Inbound connections from the guarded peer are
  not affected — the simultaneous-open race is still resolved by the
  existing check-before-insert on registration.
- The std::sync::Mutex is held for a single O(1) hash op on
  acquire / drop — never across an await — so the guard lifetime spans
  the full connect attempt without blocking anything else.

Sites wired:
- Auto-reconnect after unexpected disconnect (connection.rs ~4492)
- Rebalance-slots outgoing loop (connection.rs ~8049)
- Relay-introduction target-side both handlers (connection.rs ~3945,
  ~5783)

Tests: `pending_connect_guard_gates_same_peer_and_releases_on_drop`
asserts second same-peer acquire is refused, different peers acquire
independently, and drop releases the slot. 121 / 121 core tests pass.
2026-04-22 23:48:49 -04:00
crates Fix: dedup concurrent outgoing connects to the same peer 2026-04-22 23:48:49 -04:00
deploy ItsGoin v0.3.2 — Decentralized social media network 2026-03-15 20:23:09 -04:00
docs v0.4.1: Security hardening, lock contention fixes, data cleanup 2026-03-21 19:30:38 -04:00
frontend Phase 2c: remove audience + PostPush + PostNotification + AudienceRequest/Response 2026-04-22 22:20:02 -04:00
website v0.6.1 release: version bump + changelog 2026-04-22 17:57:28 -04:00
.gitignore Add build-appimage.sh and deploy.sh automation scripts 2026-04-19 16:01:34 -04:00
.sync-exclude.lst ItsGoin v0.3.2 — Decentralized social media network 2026-03-15 20:23:09 -04:00
ARCHITECTURE.md ItsGoin v0.3.2 — Decentralized social media network 2026-03-15 20:23:09 -04:00
build-appimage.sh Add build-appimage.sh and deploy.sh automation scripts 2026-04-19 16:01:34 -04:00
Cargo.lock v0.6.1 release: version bump + changelog 2026-04-22 17:57:28 -04:00
Cargo.toml ItsGoin v0.3.2 — Decentralized social media network 2026-03-15 20:23:09 -04:00
deploy.sh Platform: Reset wipe, empty name, Android browse + backup-off, import as personas 2026-04-22 17:40:21 -04:00
download-page.html ItsGoin v0.3.2 — Decentralized social media network 2026-03-15 20:23:09 -04:00
IMPLEMENTATION_PLAN_0.6.md Implementation plan: drop cross-version compat, beta/stable as separate networks 2026-04-21 18:26:55 -04:00
pic2.png v0.4.4: UI overhaul — sticky header, mobile nav, profiles/redundancy lightboxes 2026-03-23 00:56:27 -04:00
project discussion.txt ItsGoin v0.3.2 — Decentralized social media network 2026-03-15 20:23:09 -04:00
project-notes-from-elitebook.md ItsGoin v0.3.2 — Decentralized social media network 2026-03-15 20:23:09 -04:00
TODO.md ItsGoin v0.3.2 — Decentralized social media network 2026-03-15 20:23:09 -04:00