aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSiri Hansen <[email protected]>2018-06-14 12:21:18 +0200
committerSiri Hansen <[email protected]>2018-06-15 11:13:45 +0200
commit40f29ea1f77dec1cc4920b3593091b35b597f8ff (patch)
tree8dfade19b5b0f8f248b2c021e11f52ca6884667e
parent0c6c4c13b31f2a91568bb3a04e63bc3c878d503c (diff)
downloadotp-40f29ea1f77dec1cc4920b3593091b35b597f8ff.tar.gz
otp-40f29ea1f77dec1cc4920b3593091b35b597f8ff.tar.bz2
otp-40f29ea1f77dec1cc4920b3593091b35b597f8ff.zip
[logger] Unregister handler names before terminating
-rw-r--r--lib/kernel/src/logger_disk_log_h.erl6
-rw-r--r--lib/kernel/src/logger_std_h.erl6
2 files changed, 10 insertions, 2 deletions
diff --git a/lib/kernel/src/logger_disk_log_h.erl b/lib/kernel/src/logger_disk_log_h.erl
index a074d0210e..394c7b7320 100644
--- a/lib/kernel/src/logger_disk_log_h.erl
+++ b/lib/kernel/src/logger_disk_log_h.erl
@@ -249,7 +249,8 @@ init([Name,
max_no_files:=MNF}},
State = #{dl_sync_int := DLSyncInt}]) ->
- register(?name_to_reg_name(?MODULE,Name), self()),
+ RegName = ?name_to_reg_name(?MODULE,Name),
+ register(RegName, self()),
process_flag(trap_exit, true),
process_flag(message_queue_data, off_heap),
@@ -296,10 +297,12 @@ init([Name,
enter_loop(Config1, State1)
catch
_:Error ->
+ unregister(RegName),
logger_h_common:error_notify({open_disk_log,Name,Error}),
proc_lib:init_ack(Error)
end;
Error ->
+ unregister(RegName),
logger_h_common:error_notify({open_disk_log,Name,Error}),
proc_lib:init_ack(Error)
end.
@@ -426,6 +429,7 @@ terminate(Reason, State = #{id := Name}) ->
_ = logger_h_common:cancel_timer(maps:get(rep_sync_tref, State,
undefined)),
_ = close_disk_log(Name, normal),
+ unregister(?name_to_reg_name(?MODULE, Name)),
logger_h_common:stop_or_restart(Name, Reason, State).
code_change(_OldVsn, State, _Extra) ->
diff --git a/lib/kernel/src/logger_std_h.erl b/lib/kernel/src/logger_std_h.erl
index ce9daa50ab..801d05853a 100644
--- a/lib/kernel/src/logger_std_h.erl
+++ b/lib/kernel/src/logger_std_h.erl
@@ -229,7 +229,8 @@ log(LogEvent, Config = #{id := Name,
init([Name, Config = #{config := HConfig},
State0 = #{type := Type, file_ctrl_sync_int := FileCtrlSyncInt}]) ->
- register(?name_to_reg_name(?MODULE,Name), self()),
+ RegName = ?name_to_reg_name(?MODULE,Name),
+ register(RegName, self()),
process_flag(trap_exit, true),
process_flag(message_queue_data, off_heap),
@@ -261,10 +262,12 @@ init([Name, Config = #{config := HConfig},
enter_loop(Config1, State1)
catch
_:Error ->
+ unregister(RegName),
logger_h_common:error_notify({init_handler,Name,Error}),
proc_lib:init_ack(Error)
end;
Error ->
+ unregister(RegName),
logger_h_common:error_notify({init_handler,Name,Error}),
proc_lib:init_ack(Error)
end.
@@ -415,6 +418,7 @@ terminate(Reason, State = #{id:=Name, file_ctrl_pid:=FWPid,
false ->
ok
end,
+ unregister(?name_to_reg_name(?MODULE, Name)),
logger_h_common:stop_or_restart(Name, Reason, State).
code_change(_OldVsn, State, _Extra) ->