diff options
author | Marcus Arendt <[email protected]> | 2014-09-08 09:21:09 +0200 |
---|---|---|
committer | Marcus Arendt <[email protected]> | 2014-09-08 09:21:09 +0200 |
commit | b38e55aa8d833f9a733ac4363986e04acab9203a (patch) | |
tree | 7ae63c545dcba611f1e276b6e4088f188bf26969 /lib | |
parent | e31f40f52f2e33a1c7c4e95c4dea78c28aec2ae5 (diff) | |
parent | 5ed225662a6e48877a2ac0bef7c080297d64561e (diff) | |
download | otp-b38e55aa8d833f9a733ac4363986e04acab9203a.tar.gz otp-b38e55aa8d833f9a733ac4363986e04acab9203a.tar.bz2 otp-b38e55aa8d833f9a733ac4363986e04acab9203a.zip |
Merge branch 'lucafavatella/improve-cpu_sup-error-when-slow-port-init' into maint
* lucafavatella/improve-cpu_sup-error-when-slow-port-init:
Clarify error for slow `cpu_sup` port init
Diffstat (limited to 'lib')
-rw-r--r-- | lib/os_mon/src/cpu_sup.erl | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/os_mon/src/cpu_sup.erl b/lib/os_mon/src/cpu_sup.erl index 34251178ee..1f088ecbde 100644 --- a/lib/os_mon/src/cpu_sup.erl +++ b/lib/os_mon/src/cpu_sup.erl @@ -543,7 +543,8 @@ measurement_server_init() -> Server = case OS of {unix, Flavor} when Flavor==sunos; Flavor==linux -> - port_server_start(); + {ok, Pid} = port_server_start_link(), + Pid; {unix, Flavor} when Flavor==darwin; Flavor==freebsd; Flavor==dragonfly; @@ -588,8 +589,9 @@ measurement_server_loop(State) -> Error -> Pid ! {error, Error} end, measurement_server_loop(State); - {'EXIT', Pid, _n} when State#internal.port == Pid -> - measurement_server_loop(State#internal{port = port_server_start()}); + {'EXIT', OldPid, _n} when State#internal.port == OldPid -> + {ok, NewPid} = port_server_start_link(), + measurement_server_loop(State#internal{port = NewPid}); _Other -> measurement_server_loop(State) end. @@ -605,12 +607,12 @@ port_server_call(Pid, Command) -> {Pid, {error, Reason}} -> {error, Reason} end. -port_server_start() -> +port_server_start_link() -> Timeout = 6000, Pid = spawn_link(fun() -> port_server_init(Timeout) end), Pid ! {self(), ?ping}, receive - {Pid, {data,4711}} -> Pid; + {Pid, {data,4711}} -> {ok, Pid}; {error,Reason} -> {error, Reason} after Timeout -> {error, timeout} |