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

Improve notifications about damaged I/O subsystem #768

Closed
Closed
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
18 changes: 10 additions & 8 deletions src/rabbit_log.erl
Expand Up @@ -96,18 +96,20 @@ with_local_io(Fun) ->
Node = node(),
case node(GL) of
Node -> Fun();
_ -> set_group_leader_to_user(),
_ -> set_group_leader_to_user_safely(whereis(user)),
try
Fun()
after
group_leader(GL, self())
end
end.

set_group_leader_to_user() ->
case whereis(user) of
undefined ->
warning("the 'user' I/O process has terminated, some features will fail until Erlang VM is restarted");
User ->
group_leader(User, self())
end.
set_group_leader_to_user_safely(undefined) ->
handle_damaged_io_system();
set_group_leader_to_user_safely(User) when is_pid(User) ->
group_leader(User, self()).

handle_damaged_io_system() ->
Msg = "Erlang VM I/O system is damaged, restart needed~n",
io:format(standard_error, Msg, []),
exit(erlang_vm_restart_needed).