Fix the init_proc_mng_policy bug
Prior to this change, when the plugin like emqx_sn_gateway which has no zone run the init_proc_mng_policy function, it would trigger error and application crash. This change add a case to avoid crash.
This commit is contained in:
parent
d36a34fb59
commit
c890792613
|
@ -63,8 +63,14 @@ proc_stats(Pid) ->
|
|||
-define(DISABLED, 0).
|
||||
|
||||
init_proc_mng_policy(Zone) ->
|
||||
#{max_heap_size := MaxHeapSizeInBytes} = ShutdownPolicy =
|
||||
emqx_zone:get_env(Zone, force_shutdown_policy),
|
||||
#{max_heap_size := MaxHeapSizeInBytes}
|
||||
= ShutdownPolicy
|
||||
= case Zone of
|
||||
undefined ->
|
||||
#{max_heap_size => 0};
|
||||
_ ->
|
||||
emqx_zone:get_env(Zone, force_shutdown_policy)
|
||||
end,
|
||||
MaxHeapSize = MaxHeapSizeInBytes div erlang:system_info(wordsize),
|
||||
_ = erlang:process_flag(max_heap_size, MaxHeapSize), % zero is discarded
|
||||
erlang:put(force_shutdown_policy, ShutdownPolicy),
|
||||
|
@ -106,4 +112,3 @@ is_enabled(Max) -> is_integer(Max) andalso Max > ?DISABLED.
|
|||
proc_info(Key) ->
|
||||
{Key, Value} = erlang:process_info(self(), Key),
|
||||
Value.
|
||||
|
||||
|
|
Loading…
Reference in New Issue