فهرست منبع

Merge branch 'emq20' into develop

Feng Lee 9 سال پیش
والد
کامیت
50a5c304e2
7فایلهای تغییر یافته به همراه25 افزوده شده و 17 حذف شده
  1. 3 4
      .travis.yml
  2. 1 0
      Makefile
  3. 10 6
      src/emqttd.app.src
  4. 4 3
      src/emqttd_client.erl
  5. 5 2
      src/emqttd_gc.erl
  6. 1 1
      src/emqttd_ws_client.erl
  7. 1 1
      test/emqttd_SUITE_data/emqttd.schema

+ 3 - 4
.travis.yml

@@ -1,10 +1,9 @@
 language: erlang
 
 otp_release:
-   - 18.0
-   - 18.1
-   - 18.2.1
-   - 18.3
+   - 19.0
+   - 19.1
+   - 19.2
 
 script: 
   - make

+ 1 - 0
Makefile

@@ -4,6 +4,7 @@ PROJECT_VERSION = 2.1.0
 
 DEPS = goldrush gproc lager esockd mochiweb pbkdf2 lager_syslog
 
+
 dep_goldrush     = git https://github.com/basho/goldrush 0.1.9
 dep_gproc        = git https://github.com/uwiger/gproc
 dep_getopt       = git https://github.com/jcomellas/getopt v0.8.2

+ 10 - 6
src/emqttd.app.src

@@ -1,8 +1,12 @@
 {application, emqttd, [
-	{description, "Erlang MQTT Broker"},
-	{vsn, "2.1.0"},
-	{modules, []},
-	{registered, [emqttd_sup]},
-	{applications, [kernel,stdlib,gproc,lager,esockd,mochiweb,lager_syslog]},
-	{mod, {emqttd_app, []}}
+    {description, "Erlang MQTT Broker"},
+    {vsn, "2.1.0"},
+    {modules, []},
+    {registered, [emqttd_sup]},
+    {applications, [kernel,stdlib,gproc,lager,esockd,mochiweb,lager_syslog,pbkdf2]},
+    {env, []},
+    {mod, {emqttd_app, []}},
+    {maintainers, ["Feng Lee <feng@emqtt.io>"]},
+    {licenses, ["MIT"]},
+    {links, [{"Github", "https://github.com/emqtt/emqttd"}]}
 ]}.

+ 4 - 3
src/emqttd_client.erl

@@ -127,7 +127,7 @@ do_init(Conn, Env, Peername) ->
                                      force_gc_count = ForceGcCount}),
     IdleTimout = get_value(client_idle_timeout, Env, 30000),
     gen_server2:enter_loop(?MODULE, [], State, self(), IdleTimout,
-                           {backoff, 1000, 1000, 10000}).
+                           {backoff, 2000, 2000, 20000}).
 
 send_fun(Conn, Peername) ->
     Self = self(),
@@ -377,6 +377,7 @@ shutdown(Reason, State) ->
 stop(Reason, State) ->
     {stop, Reason, State}.
 
-gc(State) ->
-    emqttd_gc:maybe_force_gc(#client_state.force_gc_count, State).
+gc(State = #client_state{connection = Conn}) ->
+    Cb = fun() -> Conn:gc() end,
+    emqttd_gc:maybe_force_gc(#client_state.force_gc_count, State, Cb).
 

+ 5 - 2
src/emqttd_gc.erl

@@ -20,7 +20,8 @@
 
 -author("Feng Lee <feng@emqtt.io>").
 
--export([conn_max_gc_count/0, reset_conn_gc_count/2, maybe_force_gc/2]).
+-export([conn_max_gc_count/0, reset_conn_gc_count/2, maybe_force_gc/2,
+         maybe_force_gc/3]).
 
 -spec(conn_max_gc_count() -> integer()).
 conn_max_gc_count() ->
@@ -38,9 +39,11 @@ reset_conn_gc_count(Pos, State) ->
     end.
 
 maybe_force_gc(Pos, State) ->
+    maybe_force_gc(Pos, State, fun() -> ok end).
+maybe_force_gc(Pos, State, Cb) ->
     case element(Pos, State) of
         undefined     -> State;
-        I when I =< 0 -> garbage_collect(),
+        I when I =< 0 -> Cb(), garbage_collect(),
                          reset_conn_gc_count(Pos, State);
         I             -> setelement(Pos, State, I - 1)
     end.

+ 1 - 1
src/emqttd_ws_client.erl

@@ -104,7 +104,7 @@ init([Env, WsPid, Req, ReplyChannel]) ->
                          proto_state    = ProtoState,
                          enable_stats   = EnableStats,
                          force_gc_count = ForceGcCount},
-     IdleTimeout, {backoff, 1000, 1000, 10000}, ?MODULE}.
+     IdleTimeout, {backoff, 2000, 2000, 20000}, ?MODULE}.
 
 prioritise_call(Msg, _From, _Len, _State) ->
     case Msg of info -> 10; stats -> 10; state -> 10; _ -> 5 end.

+ 1 - 1
test/emqttd_SUITE_data/emqttd.schema

@@ -710,7 +710,7 @@ end}.
                             ConnOpts = Filter([{rate_limit, cuttlefish:conf_get(Key ++ ".rate_limit", Conf, undefined)}]),
                             Opts = [{connopts, ConnOpts}, {sockopts, TcpOpts(Key)} | LisOpts(Key)],
                             [{Name, Port, case Name =:= ssl orelse Name =:= https of
-                                              true  -> [{ssl, SslOpts(Key)} | Opts];
+                                              true  -> [{sslopts, SslOpts(Key)} | Opts];
                                               false -> Opts
                                           end}]
                    end