25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-20 17:27:00 +01:00

* src/ejabberd_socket.erl: Added API for monitoring socket

processes
* src/ejabberd_frontend_socket.erl: Likewise
* src/ejabberd_c2s.erl: Added socket monitoring

* src/mod_muc/mod_muc_room.erl: Fixed the stop reason for the
destroy event

SVN Revision: 751
This commit is contained in:
Alexey Shchepin 2007-04-12 06:08:32 +00:00
parent c65e1e7ae0
commit fa6b6b8f5a
5 changed files with 36 additions and 11 deletions

View File

@ -1,3 +1,13 @@
2007-04-12 Alexey Shchepin <alexey@sevcom.net>
* src/ejabberd_socket.erl: Added API for monitoring socket
processes
* src/ejabberd_frontend_socket.erl: Likewise
* src/ejabberd_c2s.erl: Added socket monitoring
* src/mod_muc/mod_muc_room.erl: Fixed the stop reason for the
destroy event
2007-04-09 Alexey Shchepin <alexey@sevcom.net>
* src/ejabberd_sm.erl: Minor optimisation

View File

@ -42,6 +42,7 @@
-record(state, {socket,
sockmod,
socket_monitor,
streamid,
sasl_state,
access,
@ -142,16 +143,18 @@ init([{SockMod, Socket}, Opts]) ->
true ->
Socket
end,
{ok, wait_for_stream, #state{socket = Socket1,
sockmod = SockMod,
zlib = Zlib,
tls = TLS,
tls_required = StartTLSRequired,
tls_enabled = TLSEnabled,
tls_options = TLSOpts,
streamid = new_id(),
access = Access,
shaper = Shaper}}.
SocketMonitor = SockMod:monitor(Socket1),
{ok, wait_for_stream, #state{socket = Socket1,
sockmod = SockMod,
socket_monitor = SocketMonitor,
zlib = Zlib,
tls = TLS,
tls_required = StartTLSRequired,
tls_enabled = TLSEnabled,
tls_options = TLSOpts,
streamid = new_id(),
access = Access,
shaper = Shaper}}.
%%----------------------------------------------------------------------
@ -1129,6 +1132,9 @@ handle_info({route, From, To, Packet}, StateName, StateData) ->
true ->
{next_state, StateName, NewState}
end;
handle_info({'DOWN', Monitor, _Type, _Object, _Info}, _StateName, StateData)
when Monitor == StateData#state.socket_monitor ->
{stop, normal, StateData};
handle_info(Info, StateName, StateData) ->
?ERROR_MSG("Unexpected info: ~p", [Info]),
{next_state, StateName, StateData}.

View File

@ -22,6 +22,7 @@
reset_stream/1,
send/2,
change_shaper/2,
monitor/1,
get_sockmod/1,
get_peer_certificate/1,
get_verify_result/1,
@ -98,6 +99,9 @@ send(FsmRef, Data) ->
change_shaper(FsmRef, Shaper) ->
gen_server:call(FsmRef, {change_shaper, Shaper}).
monitor(FsmRef) ->
erlang:monitor(process, FsmRef).
get_sockmod(FsmRef) ->
gen_server:call(FsmRef, get_sockmod).
@ -129,6 +133,7 @@ peername(FsmRef) ->
%% Description: Initiates the server
%%--------------------------------------------------------------------
init([Module, SockMod, Socket, Opts, Receiver]) ->
%% TODO: monitor the receiver
Node = ejabberd_node_groups:get_closest_node(backend),
{ok, Pid} =
rpc:call(Node, Module, start, [{?MODULE, self()}, Opts]),

View File

@ -19,6 +19,7 @@
reset_stream/1,
send/2,
change_shaper/2,
monitor/1,
get_sockmod/1,
get_peer_certificate/1,
get_verify_result/1,
@ -120,6 +121,9 @@ send(SocketData, Data) ->
change_shaper(SocketData, Shaper) ->
ejabberd_receiver:change_shaper(SocketData#socket_state.receiver, Shaper).
monitor(SocketData) ->
erlang:monitor(process, SocketData#socket_state.receiver).
get_sockmod(SocketData) ->
SocketData#socket_state.sockmod.

View File

@ -617,7 +617,7 @@ handle_event({destroy, Reason}, _StateName, StateData) ->
[{xmlelement, "reason",
[], [{xmlcdata, Reason}]}]
end}, StateData),
{stop, stopped_by_event, StateData};
{stop, normal, StateData};
handle_event(destroy, StateName, StateData) ->
handle_event({destroy, none}, StateName, StateData);