Skip to content

Preserve connect block order on rehash - #257

Merged
eaescob merged 1 commit into
masterfrom
keep-connect-order
Jun 3, 2026
Merged

Preserve connect block order on rehash#257
eaescob merged 1 commit into
masterfrom
keep-connect-order

Conversation

@eaescob

@eaescob eaescob commented May 19, 2026

Copy link
Copy Markdown
Contributor

Summary

This updates merge_connects() so /rehash rebuilds the active connect list in the order the connect {} blocks appear in the configuration file.

Previously, a fresh startup effectively restored config order because new_connects was built by head insertion and then inserted into connects by head insertion again. During /rehash, however, existing named connect blocks were updated in place, so reordering unchanged connect {} blocks in the config did not affect the active connect list until restart.

The active connect list matters for autoconnect behavior: try_connections() scans connects from the head and attempts only the first eligible uplink during a pass, then rotates that attempted entry to the end.

Changes

  • Reverse the parsed new_connects list before merging so it is processed in config-file order.
  • Detach and reuse matching existing aConnect objects so active references are preserved.
  • Keep removed but still referenced connect blocks as expired entries at the end of the list.
  • Preserve duplicate-name collapse behavior.

Validation

  • git diff --check
  • Built on eescobar@irc with autoreconf -vfi, ./configure --prefix=$HOME/dalnet/ircd, and make -j$(nproc).
  • Ran a contained test daemon on localhost, reordered two connect {} blocks, issued /rehash, and confirmed /stats c changed from uplink-a, uplink-b to uplink-b, uplink-a without restart.

@eaescob
eaescob marked this pull request as ready for review May 19, 2026 16:39
@eaescob
eaescob requested a review from crigler May 20, 2026 00:38
@eaescob
eaescob merged commit a0face1 into master Jun 3, 2026
1 check passed
@eaescob
eaescob deleted the keep-connect-order branch June 3, 2026 00:14
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