Ery Lee 11 лет назад
Родитель
Сommit
7a979e2c57
4 измененных файлов с 15 добавлено и 61 удалено
  1. 8 8
      apps/emqttd/src/emqttd_mnesia.erl
  2. 6 2
      apps/emqttd/src/emqttd_pubsub.erl
  3. 0 50
      apps/emqttd/src/x.erl
  4. 1 1
      rel/reltool.config

+ 8 - 8
apps/emqttd/src/emqttd_mnesia.erl

@@ -33,14 +33,14 @@
 -export([init/0, wait/0]).
 
 init() ->
-    case mnesia:system_info(extra_db_nodes) of
-        [] -> 
-            mnesia:stop(),
-            mnesia:create_schema([node()]);
-        _ -> 
-            ok
-    end,
-    ok = mnesia:start(),
+    %case mnesia:system_info(extra_db_nodes) of
+    %    [] -> 
+    %        mnesia:stop(),
+    %        mnesia:create_schema([node()]);
+    %    _ -> 
+    %        ok
+    %end,
+    %ok = mnesia:start(),
     create_tables().
 
 create_tables() ->

+ 6 - 2
apps/emqttd/src/emqttd_pubsub.erl

@@ -232,22 +232,26 @@ init([]) ->
 		{ram_copies, [node()]},
 		{attributes, record_info(fields, topic_trie)}]),
 	mnesia:add_table_copy(topic_trie, node(), ram_copies),
+    Result =
 	mnesia:create_table(topic, [
 		{type, bag},
 		{record_name, topic},
 		{ram_copies, [node()]}, 
 		{attributes, record_info(fields, topic)}]),
+    io:format("~p~n", [Result]),
 	mnesia:add_table_copy(topic, node(), ram_copies),
     mnesia:subscribe({table, topic, simple}),
     %% local table, not shared with other table
+    Result1 =
     mnesia:create_table(topic_subscriber, [
 		{type, bag},
 		{record_name, topic_subscriber},
 		{ram_copies, [node()]},
 		{attributes, record_info(fields, topic_subscriber)},
-        {index, [subpid]},
-        {local_content, true}]),
+        {index, [subpid]}]),
+        %{local_content, true}]),
     mnesia:subscribe({table, topic_subscriber, simple}),
+    io:format("~p~n", [Result1]),
 	{ok, #state{}}.
 
 handle_call(getstats, _From, State = #state{max_subs = Max}) ->

+ 0 - 50
apps/emqttd/src/x.erl

@@ -1,50 +0,0 @@
--module(x).
--behaviour(gen_server).
--define(SERVER, ?MODULE).
-
-%% ------------------------------------------------------------------
-%% API Function Exports
-%% ------------------------------------------------------------------
-
--export([start_link/0]).
-
-%% ------------------------------------------------------------------
-%% gen_server Function Exports
-%% ------------------------------------------------------------------
-
--export([init/1, handle_call/3, handle_cast/2, handle_info/2,
-         terminate/2, code_change/3]).
-
-%% ------------------------------------------------------------------
-%% API Function Definitions
-%% ------------------------------------------------------------------
-
-start_link() ->
-    gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).
-
-%% ------------------------------------------------------------------
-%% gen_server Function Definitions
-%% ------------------------------------------------------------------
-
-init(Args) ->
-    {ok, Args}.
-
-handle_call(_Request, _From, State) ->
-    {reply, ok, State}.
-
-handle_cast(_Msg, State) ->
-    {noreply, State}.
-
-handle_info(_Info, State) ->
-    {noreply, State}.
-
-terminate(_Reason, _State) ->
-    ok.
-
-code_change(_OldVsn, State, _Extra) ->
-    {ok, State}.
-
-%% ------------------------------------------------------------------
-%% Internal Function Definitions
-%% ------------------------------------------------------------------
-

+ 1 - 1
rel/reltool.config

@@ -10,7 +10,7 @@
 		 syntax_tools,
 		 ssl,
 		 crypto,
-         %mnesia,
+         mnesia,
 		 os_mon,
 		 inets,
 		 goldrush,