From 78dd1f8838f5ea1908da9c3acee700eca73233cc Mon Sep 17 00:00:00 2001 From: Feng Date: Wed, 23 Dec 2015 22:33:49 +0800 Subject: [PATCH 1/2] fix issue #413 --- src/emqttd_ws_client.erl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/emqttd_ws_client.erl b/src/emqttd_ws_client.erl index 9529ba42a..196e7d5d1 100644 --- a/src/emqttd_ws_client.erl +++ b/src/emqttd_ws_client.erl @@ -223,8 +223,18 @@ handle_info({keepalive, check}, State = #wsclient_state{request = Req, handle_info({'EXIT', WsPid, Reason}, State = #wsclient_state{ws_pid = WsPid}) -> stop(Reason, State); +handle_info({'EXIT', SessPid, Reason}, State = #wsclient_state{request = Req, + proto_state = ProtoState}) -> + case emqttd_protocol:session(ProtoState) of + SessPid -> + stop(Reason, State); + ExitPid -> + ?WSLOG(error, "Unexpected EXIT ~p for ~p", [ExitPid, Reason], Req), + noreply(State) + end; + handle_info(Info, State = #wsclient_state{request = Req}) -> - ?WSLOG(error, "Unexpected Info: ~p", [Info], Req), + ?WSLOG(critical, "Unexpected Info: ~p", [Info], Req), noreply(State). terminate(Reason, #wsclient_state{proto_state = ProtoState, keepalive = KeepAlive}) -> From 2dd8c3d7781580328b480360a47e2b12658486bb Mon Sep 17 00:00:00 2001 From: Feng Date: Wed, 23 Dec 2015 23:20:05 +0800 Subject: [PATCH 2/2] remove trap_exit flag, and fix issue #413 --- src/emqttd_ws_client.erl | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/emqttd_ws_client.erl b/src/emqttd_ws_client.erl index 196e7d5d1..8b06d9367 100644 --- a/src/emqttd_ws_client.erl +++ b/src/emqttd_ws_client.erl @@ -123,7 +123,8 @@ reset_parser(State = #wsocket_state{packet_opts = PktOpts}) -> %%%============================================================================= init([WsPid, Req, ReplyChannel, PktOpts]) -> - process_flag(trap_exit, true), + %%issue#413: trap_exit is unnecessary + %%process_flag(trap_exit, true), {ok, Peername} = Req:get(peername), SendFun = fun(Payload) -> ReplyChannel({binary, Payload}) end, Headers = mochiweb_request:get(headers, Req), @@ -220,18 +221,9 @@ handle_info({keepalive, check}, State = #wsclient_state{request = Req, shutdown(keepalive_error, State) end; -handle_info({'EXIT', WsPid, Reason}, State = #wsclient_state{ws_pid = WsPid}) -> - stop(Reason, State); - -handle_info({'EXIT', SessPid, Reason}, State = #wsclient_state{request = Req, - proto_state = ProtoState}) -> - case emqttd_protocol:session(ProtoState) of - SessPid -> - stop(Reason, State); - ExitPid -> - ?WSLOG(error, "Unexpected EXIT ~p for ~p", [ExitPid, Reason], Req), - noreply(State) - end; +%%issue#413: removed the trap_exit flag +%%handle_info({'EXIT', WsPid, Reason}, State = #wsclient_state{ws_pid = WsPid}) -> +%% stop(Reason, State); handle_info(Info, State = #wsclient_state{request = Req}) -> ?WSLOG(critical, "Unexpected Info: ~p", [Info], Req),