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

Fix self connecting error on OTP 21 #17

Merged
merged 2 commits into from
Jul 4, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion lib/peerage/server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ defmodule Peerage.Server do
defp discover do
poll()
|> only_fresh_node_names
|> Enum.map(&([&1, Node.connect(&1)]))
|> Enum.map(&([&1, connect_to_node(&1)]))
|> log_results
end

Expand Down Expand Up @@ -76,6 +76,15 @@ defmodule Peerage.Server do
defp sync_offset do
Application.get_env(:peerage, :sync_offset, @default_sync_offset)
end

defp connect_to_node(node_name) do
# Avoid self connecting.
if node() != node_name do
Node.connect(node_name)
else
true
end
end
end