Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: observe listen port occupancy #3231

Merged
merged 1 commit into from
Dec 21, 2021

Conversation

driftluo
Copy link
Collaborator

What problem does this PR solve?

Since the port reuse function of ckb is enabled by default on Linux, starting two ckb nodes will not report an error explicitly, after this PR will automatically exit the second ckb node

Check List

Tests

Manual test:

  1. start 2 ckb nodes with the same net port
  2. the second one will stop with an error
2021-12-13 17:21:31.585 +08:00 main INFO ckb_bin::helper  raise_fd_limit newly-increased limit: 524288                                 
2021-12-13 17:21:34.235 +08:00 main INFO ckb_bin::subcommand::run  ckb version: 0.102.0-pre (1595009-dirty 2021-12-13)                 
2021-12-13 17:21:34.236 +08:00 main INFO ckb_launcher  Miner is disabled, edit ckb.toml to enable it                                   
IO Error: Os { code: 98, kind: AddrInUse, message: "Address already in use" }                                                          
2021-12-13 17:21:34.236 +08:00 main INFO ckb_stop_handler  StopHandler(GT) send signal

Release note

Title Only: Include only the PR title in the release note.

util/launcher/src/lib.rs Outdated Show resolved Hide resolved
@keroro520 keroro520 dismissed their stale review December 13, 2021 11:01

I don't insist on it

network/src/lib.rs Outdated Show resolved Hide resolved
@driftluo driftluo force-pushed the observe-listen-port branch 3 times, most recently from 282b0a5 to 515935d Compare December 14, 2021 03:06
network/src/lib.rs Outdated Show resolved Hide resolved
@chanhsu001
Copy link
Contributor

I checked with 2 testcases:
pc with 2 network interface: eth0 and eth1, with different IP address.

  1. ckb instance A with ckb.toml, network listen_address=["/ipv4/eth0_ip/tcp/8115"]
    ckb instance B with ckb.toml, network listen_address=["/ipv4/eth1_ip/tcp/8115"]
    both ckb instance start and work, without conflict.

  2. ckb instance A with ckb.toml, network listen_address=["/ipv4/eth0_ip/tcp/8115"]
    ckb instance B with ckb.toml, network listen_address=["/ipv4/0.0.0.0/tcp/8115"]
    only one instance could start, the other will report "Address already in use" error and exit

It conform to the design.
Any more running CKB instances will have to binding the explicit different IP address in their ckb.toml , network part.

network/src/lib.rs Outdated Show resolved Hide resolved
@driftluo
Copy link
Collaborator Author

bors r=quake,doitian

@bors bors bot merged commit 75b0a36 into nervosnetwork:develop Dec 21, 2021
@driftluo driftluo deleted the observe-listen-port branch December 21, 2021 07:48
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.

5 participants