From c581c59908b4e8cc17e27cfe69aa9850c6764013 Mon Sep 17 00:00:00 2001 From: Feng Lee Date: Wed, 16 Sep 2015 21:44:25 +0800 Subject: [PATCH 1/5] fix issue #291 --- rel/vars.config | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rel/vars.config b/rel/vars.config index d6a109ba5..982940a28 100644 --- a/rel/vars.config +++ b/rel/vars.config @@ -24,6 +24,5 @@ {runner_base_dir, "${RUNNER_SCRIPT_DIR%/*}"}. {runner_etc_dir, "$RUNNER_BASE_DIR/etc"}. {runner_log_dir, "$RUNNER_BASE_DIR/log"}. -{pipe_dir, "/tmp/$RUNNER_BASE_DIR/"}. +{pipe_dir, "/tmp/$RUNNER_SCRIPT/"}. {runner_user, ""}. - From 12b4bc96975e7919c1a437b220b6666f27cdfa0f Mon Sep 17 00:00:00 2001 From: Feng Lee Date: Wed, 16 Sep 2015 21:52:18 +0800 Subject: [PATCH 2/5] misc --- src/emqttd_trace.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/emqttd_trace.erl b/src/emqttd_trace.erl index c67677747..82cd4d8a7 100644 --- a/src/emqttd_trace.erl +++ b/src/emqttd_trace.erl @@ -89,9 +89,9 @@ init([]) -> handle_call({start_trace, Who, LogFile}, _From, State = #state{level = Level, trace_map = TraceMap}) -> case lager:trace_file(LogFile, [Who], Level, ?TRACE_OPTIONS) of - {ok, exists} -> + {ok, exists} -> {reply, {error, existed}, State}; - {ok, Trace} -> + {ok, Trace} -> {reply, ok, State#state{trace_map = maps:put(Who, {Trace, LogFile}, TraceMap)}}; {error, Error} -> {reply, {error, Error}, State} From 3e899ab7a2ebb1f440b8468bbb799fc54e7be837 Mon Sep 17 00:00:00 2001 From: Feng Lee Date: Wed, 16 Sep 2015 22:11:17 +0800 Subject: [PATCH 3/5] fix issue #284 - the stupid list_to_atom... --- src/emqttd_sm.erl | 2 +- src/emqttd_vm.erl | 64 ++++++++++------------------------------------- 2 files changed, 14 insertions(+), 52 deletions(-) diff --git a/src/emqttd_sm.erl b/src/emqttd_sm.erl index c45b1d95a..c17203f80 100644 --- a/src/emqttd_sm.erl +++ b/src/emqttd_sm.erl @@ -267,7 +267,7 @@ resume_session(Session = #mqtt_session{client_id = ClientId, {badrpc, Reason} -> lager:critical("Resume session ~s on remote node ~p failed for ~p", [ClientId, Node, Reason]), - {error, list_to_atom("session_" ++ atom_to_list(Reason))} + {error, Reason} end; false -> lager:critical("Session ~s died for node ~p down!", [ClientId, Node]), diff --git a/src/emqttd_vm.erl b/src/emqttd_vm.erl index 1c2181ccf..3836f0587 100644 --- a/src/emqttd_vm.erl +++ b/src/emqttd_vm.erl @@ -27,6 +27,8 @@ -module(emqttd_vm). +-author('huangdan'). + -export([schedulers/0]). -export([microsecs/0]). @@ -39,7 +41,7 @@ get_process_info/0, get_process_gc/0, get_process_group_leader_info/1, - get_process_limit/0]). + get_process_limit/0]). -export([get_ets_list/0, get_ets_info/0, @@ -59,8 +61,7 @@ sl_alloc, ll_alloc, fix_alloc, - std_alloc - ]). + std_alloc]). -define(PROCESS_LIST, [initial_call, reductions, @@ -139,8 +140,7 @@ trace_control_word, update_cpu_info, version, - wordsize - ]). + wordsize]). -define(SOCKET_OPTS, [active, broadcast, @@ -175,8 +175,8 @@ microsecs() -> (Mega * 1000000 + Sec) * 1000000 + Micro. loads() -> - [{load1, ftos(cpu_sup:avg1()/256)}, - {load5, ftos(cpu_sup:avg5()/256)}, + [{load1, ftos(cpu_sup:avg1()/256)}, + {load5, ftos(cpu_sup:avg5()/256)}, {load15, ftos(cpu_sup:avg15()/256)}]. get_system_info() -> @@ -306,24 +306,20 @@ get_process_list()-> [get_process_list(Pid) || Pid <- processes()]. get_process_list(Pid) when is_pid(Pid) -> - Info = [process_info(Pid, Key) || Key <- ?PROCESS_LIST], - [{pid, pid_port_fun_to_atom(Pid)}] ++ lists:flatten([convert_pid_info(Item) || Item <- Info]). + [{pid, Pid} | [process_info(Pid, Key) || Key <- ?PROCESS_LIST]]. get_process_info() -> [get_process_info(Pid) || Pid <- processes()]. get_process_info(Pid) when is_pid(Pid) -> - ProcessInfo = [process_info(Pid, Key) || Key <- ?PROCESS_INFO], - lists:flatten([convert_pid_info(Item) || Item <- ProcessInfo]). + [process_info(Pid, Key) || Key <- ?PROCESS_INFO]. get_process_gc() -> [get_process_gc(Pid) || Pid <- processes()]. get_process_gc(Pid) when is_pid(Pid) -> - GcInfo = [process_info(Pid, Key) || Key <- ?PROCESS_GC], - lists:flatten([convert_pid_info(E) || E <- GcInfo]). + [process_info(Pid, Key) || Key <- ?PROCESS_GC]. get_process_group_leader_info(LeaderPid) when is_pid(LeaderPid) -> - LeaderInfo = [{Key, Value}|| {Key, Value} <- process_info(LeaderPid), lists:member(Key, ?PROCESS_INFO)], - lists:flatten([convert_pid_info(E) || E <- LeaderInfo]). + [{Key, Value}|| {Key, Value} <- process_info(LeaderPid), lists:member(Key, ?PROCESS_INFO)]. get_process_limit() -> erlang:system_info(process_limit). @@ -453,41 +449,7 @@ mapping([], Acc) -> mapping([{owner, V}|Entries], Acc) when is_pid(V) -> OwnerInfo = process_info(V), Owner = proplists:get_value(registered_name, OwnerInfo, undefined), - mapping(Entries, [{owner, pid_port_fun_to_atom(Owner)}|Acc]); + mapping(Entries, [{owner, Owner}|Acc]); mapping([{Key, Value}|Entries], Acc) -> - mapping(Entries, [{Key, pid_port_fun_to_atom(Value)}|Acc]). + mapping(Entries, [{Key, Value}|Acc]). -%ip_to_binary(Tuple) -> -% iolist_to_binary(string:join(lists:map(fun integer_to_list/1, tuple_to_list(Tuple)), ".")). - -convert_pid_info({initial_call,{_M, F, _A}}) -> - {initial_call, F}; -convert_pid_info({current_function, {M, F, A}}) -> - {current_function, list_to_atom(lists:concat([atom_to_list(M),":",atom_to_list(F),"/",integer_to_list(A)]))}; -convert_pid_info({suspending, List}) -> - {suspending, [pid_port_fun_to_atom(E) || E <- List]}; -convert_pid_info({binary, List}) -> - {binary,[tuple_to_list(E) || E <- List]}; -convert_pid_info({Key, Term}) when is_pid(Term) or is_port(Term) or is_function(Term) -> - {Key, pid_port_fun_to_atom(Term)}; -convert_pid_info(Item) -> - Item. - -%convert_port_info({name, Name}) -> -% {name, list_to_binary(Name)}; -%convert_port_info({links, List}) -> -% {links, [pid_port_fun_to_atom(Item) || Item <- List]}; -%convert_port_info({connected, Pid}) -> -% erlang:process_info(Pid, registered_name); -%convert_port_info(Item) -> -% Item. - - -pid_port_fun_to_atom(Term) when is_pid(Term) -> - erlang:list_to_atom(pid_to_list(Term)); -pid_port_fun_to_atom(Term) when is_port(Term) -> - erlang:list_to_atom(erlang:port_to_list(Term)); -pid_port_fun_to_atom(Term) when is_function(Term) -> - erlang:list_to_atom(erlang:fun_to_list(Term)); -pid_port_fun_to_atom(Term) -> - Term. From 107c317e1159c1868152d96a376d5753f595d2c1 Mon Sep 17 00:00:00 2001 From: Feng Lee Date: Wed, 16 Sep 2015 22:19:02 +0800 Subject: [PATCH 4/5] 10000 --- src/emqttd_pubsub_sup.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/emqttd_pubsub_sup.erl b/src/emqttd_pubsub_sup.erl index fb58ec74a..e1c5095cf 100644 --- a/src/emqttd_pubsub_sup.erl +++ b/src/emqttd_pubsub_sup.erl @@ -52,7 +52,7 @@ init([]) -> Name = {emqttd_pubsub, I}, gproc_pool:add_worker(pubsub, Name, I), {Name, {emqttd_pubsub, start_link, [I, Opts]}, - permanent, 5000, worker, [emqttd_pubsub]} + permanent, 10000, worker, [emqttd_pubsub]} end, lists:seq(1, PoolSize)), {ok, {{one_for_all, 10, 100}, Children}}. From d072d001a2b18bc80d9950502b4d376263fe1b07 Mon Sep 17 00:00:00 2001 From: Feng Lee Date: Wed, 16 Sep 2015 22:19:42 +0800 Subject: [PATCH 5/5] pubsub pool_size 8 --- rel/files/emqttd.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rel/files/emqttd.config b/rel/files/emqttd.config index 3a8155feb..3980fba81 100644 --- a/rel/files/emqttd.config +++ b/rel/files/emqttd.config @@ -141,7 +141,7 @@ %% PubSub {pubsub, [ %% default should be scheduler numbers - %% {pool_size, 4} + %% {pool_size, 8} ]}, %% Bridge {bridge, [