diff --git a/src/proxyPt/ntPptAcceptor.erl b/src/proxyPt/ntPptAcceptor.erl index ccfa255..344f188 100644 --- a/src/proxyPt/ntPptAcceptor.erl +++ b/src/proxyPt/ntPptAcceptor.erl @@ -44,8 +44,8 @@ system_get_state(State) -> {ok, State}. -spec system_terminate(term(), pid(), [], term()) -> none(). -system_terminate(Reason, _Parent, _Debug, _State) -> - exit(Reason). +system_terminate(Reason, _Parent, _Debug, State) -> + terminate(Reason, State). modInit(Parent, Args) -> case init(Args) of @@ -62,7 +62,7 @@ loop(Parent, State) -> {system, From, Request} -> sys:handle_system_msg(Request, From, Parent, ?MODULE, [], {Parent, State}); {'EXIT', Parent, Reason} -> - exit(Reason); + terminate(Reason, State); Msg -> case handleMsg(Msg, State) of kpS -> @@ -70,7 +70,7 @@ loop(Parent, State) -> {ok, NewState} -> loop(Parent, NewState); {stop, Reason} -> - exit(Reason) + terminate(Reason, State) end end. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% genActor end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -130,6 +130,9 @@ handleMsg({inet_async, LSock, Ref, Msg}, #state{lSock = LSock, sslOpts = SslOpts handleMsg(_Msg, _State) -> kpS. +terminate(Reason, _State) -> + exit(Reason). + newAsyncAccept(LSock, State) -> case prim_inet:async_accept(LSock, -1) of {ok, Ref} -> diff --git a/src/proxyPt/ntPptListener.erl b/src/proxyPt/ntPptListener.erl index a12a1ca..ff03f48 100644 --- a/src/proxyPt/ntPptListener.erl +++ b/src/proxyPt/ntPptListener.erl @@ -45,8 +45,8 @@ system_get_state(State) -> {ok, State}. -spec system_terminate(term(), pid(), [], term()) -> none(). -system_terminate(Reason, _Parent, _Debug, _State) -> - exit(Reason). +system_terminate(Reason, _Parent, _Debug, State) -> + terminate(Reason, State). safeRegister(Name) -> try register(Name, self()) of @@ -78,8 +78,7 @@ loop(Parent, State) -> {ok, NewState} -> loop(Parent, NewState); {stop, Reason} -> - terminate(Reason, State), - exit(Reason) + terminate(Reason, State) end end. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% genActor end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -119,11 +118,11 @@ handleMsg({'$gen_call', From, miListenPort}, #state{listenPort = LPort} = _State handleMsg(_Msg, _State) -> kpS. -terminate(_Reason, #state{lSock = LSock, listenAddr = Addr, listenPort = Port}) -> +terminate(Reason, #state{lSock = LSock, listenAddr = Addr, listenPort = Port}) -> ?ntInfo("stopped on ~s:~p ~n", [inet:ntoa(Addr), Port]), %% 关闭这个监听LSock 监听进程收到tcp_close 然后终止acctptor进程 catch port_close(LSock), - ok. + exit(Reason). startAcceptor(0, _LSock, _AptSupName, _ConMod, _ConArgs) -> ok; diff --git a/src/ssl/ntSslAcceptor.erl b/src/ssl/ntSslAcceptor.erl index 40b34c7..5b039b6 100644 --- a/src/ssl/ntSslAcceptor.erl +++ b/src/ssl/ntSslAcceptor.erl @@ -43,8 +43,8 @@ system_get_state(State) -> {ok, State}. -spec system_terminate(term(), pid(), [], term()) -> none(). -system_terminate(Reason, _Parent, _Debug, _State) -> - exit(Reason). +system_terminate(Reason, _Parent, _Debug, State) -> + terminate(Reason, State). modInit(Parent, Args) -> case init(Args) of @@ -61,7 +61,7 @@ loop(Parent, State) -> {system, From, Request} -> sys:handle_system_msg(Request, From, Parent, ?MODULE, [], {Parent, State}); {'EXIT', Parent, Reason} -> - exit(Reason); + terminate(Reason, State); Msg -> case handleMsg(Msg, State) of kpS -> @@ -69,7 +69,7 @@ loop(Parent, State) -> {ok, NewState} -> loop(Parent, NewState); {stop, Reason} -> - exit(Reason) + terminate(Reason, State) end end. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% genActor end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -127,6 +127,9 @@ handleMsg({inet_async, LSock, Ref, Msg}, #state{lSock = LSock, sslOpts = SslOpts handleMsg(_Msg, _State) -> kpS. +terminate(Reason, _State) -> + exit(Reason). + newAsyncAccept(LSock, State) -> case prim_inet:async_accept(LSock, -1) of {ok, Ref} -> diff --git a/src/ssl/ntSslListener.erl b/src/ssl/ntSslListener.erl index 677af64..158ec9c 100644 --- a/src/ssl/ntSslListener.erl +++ b/src/ssl/ntSslListener.erl @@ -45,8 +45,8 @@ system_get_state(State) -> {ok, State}. -spec system_terminate(term(), pid(), [], term()) -> none(). -system_terminate(Reason, _Parent, _Debug, _State) -> - exit(Reason). +system_terminate(Reason, _Parent, _Debug, State) -> + terminate(Reason, State). safeRegister(Name) -> try register(Name, self()) of @@ -78,8 +78,7 @@ loop(Parent, State) -> {ok, NewState} -> loop(Parent, NewState); {stop, Reason} -> - terminate(Reason, State), - exit(Reason) + terminate(Reason, State) end end. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% genActor end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -119,11 +118,11 @@ handleMsg({'$gen_call', From, miListenPort}, #state{listenPort = LPort} = _State handleMsg(_Msg, _State) -> kpS. -terminate(_Reason, #state{lSock = LSock, listenAddr = Addr, listenPort = Port}) -> +terminate(Reason, #state{lSock = LSock, listenAddr = Addr, listenPort = Port}) -> ?ntInfo("stopped on ~s:~p ~n", [inet:ntoa(Addr), Port]), %% 关闭这个监听LSock 监听进程收到tcp_close 然后终止acctptor进程 catch port_close(LSock), - ok. + exit(Reason). startAcceptor(0, _LSock, _AptSupName, _ConMod, _ConArgs) -> ok; diff --git a/src/tcp/ntTcpAcceptor.erl b/src/tcp/ntTcpAcceptor.erl index 29ed002..d0af7bc 100644 --- a/src/tcp/ntTcpAcceptor.erl +++ b/src/tcp/ntTcpAcceptor.erl @@ -41,8 +41,8 @@ system_get_state(State) -> {ok, State}. -spec system_terminate(term(), pid(), [], term()) -> none(). -system_terminate(Reason, _Parent, _Debug, _State) -> - exit(Reason). +system_terminate(Reason, _Parent, _Debug, State) -> + terminate(Reason, State). modInit(Parent, Args) -> case init(Args) of @@ -59,7 +59,7 @@ loop(Parent, State) -> {system, From, Request} -> sys:handle_system_msg(Request, From, Parent, ?MODULE, [], {Parent, State}); {'EXIT', Parent, Reason} -> - exit(Reason); + terminate(Reason, State); Msg -> case handleMsg(Msg, State) of kpS -> @@ -67,7 +67,7 @@ loop(Parent, State) -> {ok, NewState} -> loop(Parent, NewState); {stop, Reason} -> - exit(Reason) + terminate(Reason, State) end end. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% genActor end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -123,6 +123,9 @@ handleMsg({inet_async, LSock, Ref, Msg}, #state{lSock = LSock, ref = Ref, conMod handleMsg(_Msg, _State) -> kpS. +terminate(Reason, _State) -> + exit(Reason). + newAsyncAccept(LSock, State) -> case prim_inet:async_accept(LSock, -1) of {ok, Ref} -> diff --git a/src/tcp/ntTcpListener.erl b/src/tcp/ntTcpListener.erl index 2c4c410..25b452c 100644 --- a/src/tcp/ntTcpListener.erl +++ b/src/tcp/ntTcpListener.erl @@ -45,8 +45,8 @@ system_get_state(State) -> {ok, State}. -spec system_terminate(term(), pid(), [], term()) -> none(). -system_terminate(Reason, _Parent, _Debug, _State) -> - exit(Reason). +system_terminate(Reason, _Parent, _Debug, State) -> + terminate(Reason, State). safeRegister(Name) -> try register(Name, self()) of @@ -78,8 +78,7 @@ loop(Parent, State) -> {ok, NewState} -> loop(Parent, NewState); {stop, Reason} -> - terminate(Reason, State), - exit(Reason) + terminate(Reason, State) end end. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% genActor end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -119,11 +118,11 @@ handleMsg({'$gen_call', From, miListenPort}, #state{listenPort = LPort} = _State handleMsg(_Msg, _State) -> kpS. -terminate(_Reason, #state{lSock = LSock, listenAddr = Addr, listenPort = Port}) -> +terminate(Reason, #state{lSock = LSock, listenAddr = Addr, listenPort = Port}) -> ?ntInfo("stopped on ~s:~p ~n", [inet:ntoa(Addr), Port]), %% 关闭这个监听LSock 监听进程收到tcp_close 然后终止acctptor进程 catch port_close(LSock), - ok. + exit(Reason). startAcceptor(0, _LSock, _AptSupName, _ConMod, _ConArgs) -> ok; diff --git a/src/udp/ntUdpSrv.erl b/src/udp/ntUdpSrv.erl index 0535fd3..add7e04 100644 --- a/src/udp/ntUdpSrv.erl +++ b/src/udp/ntUdpSrv.erl @@ -45,8 +45,8 @@ system_get_state(State) -> {ok, State}. -spec system_terminate(term(), pid(), [], term()) -> none(). -system_terminate(Reason, _Parent, _Debug, _State) -> - exit(Reason). +system_terminate(Reason, _Parent, _Debug, State) -> + terminate(Reason, State). safeRegister(Name) -> try register(Name, self()) of @@ -78,8 +78,7 @@ loop(Parent, State) -> {ok, NewState} -> loop(Parent, NewState); {stop, Reason} -> - terminate(Reason, State), - exit(Reason) + terminate(Reason, State) end end. @@ -175,10 +174,10 @@ handleMsg(_Msg, _State) -> ?ntErr("~p unexpected info: ~p ~n", [?MODULE, _Msg]), kpS. -terminate(_Reason, #state{oSock = LSock, listenAddr = Addr, listenPort = Port}) -> +terminate(Reason, #state{oSock = LSock, listenAddr = Addr, listenPort = Port}) -> ?ntInfo("stopped on ~s:~p ~n", [inet:ntoa(Addr), Port]), catch gen_udp:close(LSock), - ok. + exit(Reason). -spec getOpts(pid()) -> [listenOpt()]. getOpts(Listener) ->