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

[TECH-1511] debug traces reorganized

This commit is contained in:
Eric Cestari 2010-09-16 15:08:53 +02:00
parent cb54444f00
commit a45ecb70ff
4 changed files with 5 additions and 15 deletions

View File

@ -75,7 +75,7 @@ update_reg_users_counter_table(Server) ->
mnesia:sync_dirty(F). mnesia:sync_dirty(F).
plain_password_required() -> plain_password_required() ->
true. false.
check_password(User, Server, Password) -> check_password(User, Server, Password) ->
LUser = jlib:nodeprep(User), LUser = jlib:nodeprep(User),

View File

@ -330,10 +330,6 @@ process(Handlers, #ws{} = Ws)->
(HandlerPathPrefix==Ws#ws.path)) of (HandlerPathPrefix==Ws#ws.path)) of
true -> true ->
?DEBUG("~p matches ~p", [Ws#ws.path, HandlerPathPrefix]), ?DEBUG("~p matches ~p", [Ws#ws.path, HandlerPathPrefix]),
%% LocalPath is the path "local to the handler", i.e. if
%% the handler was registered to handle "/test/" and the
%% requested path is "/test/foo/bar", the local path is
%% ["foo", "bar"]
LocalPath = lists:nthtail(length(HandlerPathPrefix), Ws#ws.path), LocalPath = lists:nthtail(length(HandlerPathPrefix), Ws#ws.path),
ejabberd_hooks:run(ws_debug, [{LocalPath, Ws}]), ejabberd_hooks:run(ws_debug, [{LocalPath, Ws}]),
ejabberd_websocket:connect(Ws#ws{local_path = LocalPath}, HandlerModule); ejabberd_websocket:connect(Ws#ws{local_path = LocalPath}, HandlerModule);
@ -410,6 +406,7 @@ process_request(#state{request_method = Method,
headers = RequestHeaders headers = RequestHeaders
}, },
process(WebSocketHandlers, Ws), process(WebSocketHandlers, Ws),
?DEBUG("It is a websocket.",[]),
none; none;
false -> false ->
Request = #request{method = Method, Request = #request{method = Method,
@ -422,7 +419,6 @@ process_request(#state{request_method = Method,
tp = TP, tp = TP,
headers = RequestHeaders, headers = RequestHeaders,
ip = IP}, ip = IP},
?DEBUG("It is not a websocket.",[]),
case process(RequestHandlers, Request) of case process(RequestHandlers, Request) of
El when element(1, El) == xmlelement -> El when element(1, El) == xmlelement ->
make_xhtml_output(State, 200, [], El); make_xhtml_output(State, 200, [], El);

View File

@ -76,7 +76,7 @@ start(WS) ->
supervisor:start_child(ejabberd_wsloop_sup, [WS]). supervisor:start_child(ejabberd_wsloop_sup, [WS]).
start_link(WS) -> start_link(WS) ->
gen_fsm:start_link(?MODULE, [WS],[{debug, [trace]}]). gen_fsm:start_link(?MODULE, [WS],?FSMOPTS).
send({http_ws, FsmRef, _IP}, Packet) -> send({http_ws, FsmRef, _IP}, Packet) ->
gen_fsm:sync_send_all_state_event(FsmRef, {send, Packet}). gen_fsm:sync_send_all_state_event(FsmRef, {send, Packet}).

View File

@ -44,7 +44,6 @@
-include("ejabberd_http.hrl"). -include("ejabberd_http.hrl").
check(_Path, Headers)-> check(_Path, Headers)->
%?DEBUG("testing for a websocket request path: ~p headers: ~p", [_Path, Headers]),
% set supported websocket protocols, order does matter % set supported websocket protocols, order does matter
VsnSupported = [{'draft-hixie', 76}, {'draft-hixie', 68}], VsnSupported = [{'draft-hixie', 76}, {'draft-hixie', 68}],
% checks % checks
@ -198,7 +197,7 @@ ws_loop(Socket, Buffer, WsHandleLoopPid, SocketMode, WsAutoExit) ->
{tcp, Socket, Data} -> {tcp, Socket, Data} ->
handle_data(Buffer, binary_to_list(Data), Socket, WsHandleLoopPid, SocketMode, WsAutoExit); handle_data(Buffer, binary_to_list(Data), Socket, WsHandleLoopPid, SocketMode, WsAutoExit);
{tcp_closed, Socket} -> {tcp_closed, Socket} ->
%?DEBUG("tcp connection was closed, exit", []), ?DEBUG("tcp connection was closed, exit", []),
% close websocket and custom controlling loop % close websocket and custom controlling loop
websocket_close(Socket, WsHandleLoopPid, SocketMode, WsAutoExit); websocket_close(Socket, WsHandleLoopPid, SocketMode, WsAutoExit);
{'DOWN', Ref, process, WsHandleLoopPid, Reason} -> {'DOWN', Ref, process, WsHandleLoopPid, Reason} ->
@ -218,7 +217,7 @@ ws_loop(Socket, Buffer, WsHandleLoopPid, SocketMode, WsAutoExit) ->
SocketMode:send(Socket, [0, Data, 255]), SocketMode:send(Socket, [0, Data, 255]),
ws_loop(Socket, Buffer, WsHandleLoopPid, SocketMode, WsAutoExit); ws_loop(Socket, Buffer, WsHandleLoopPid, SocketMode, WsAutoExit);
shutdown -> shutdown ->
%?DEBUG("shutdown request received, closing websocket with pid ~p", [self()]), ?DEBUG("shutdown request received, closing websocket with pid ~p", [self()]),
% close websocket and custom controlling loop % close websocket and custom controlling loop
websocket_close(Socket, WsHandleLoopPid, SocketMode, WsAutoExit); websocket_close(Socket, WsHandleLoopPid, SocketMode, WsAutoExit);
_Ignored -> _Ignored ->
@ -228,24 +227,19 @@ ws_loop(Socket, Buffer, WsHandleLoopPid, SocketMode, WsAutoExit) ->
% Buffering and data handling % Buffering and data handling
handle_data(none, [0|T], Socket, WsHandleLoopPid, SocketMode, WsAutoExit) -> handle_data(none, [0|T], Socket, WsHandleLoopPid, SocketMode, WsAutoExit) ->
%?DEBUG("handle_data 1", []),
handle_data([], T, Socket, WsHandleLoopPid, SocketMode, WsAutoExit); handle_data([], T, Socket, WsHandleLoopPid, SocketMode, WsAutoExit);
handle_data(none, [], Socket, WsHandleLoopPid, SocketMode, WsAutoExit) -> handle_data(none, [], Socket, WsHandleLoopPid, SocketMode, WsAutoExit) ->
%?DEBUG("handle_data 2", []),
ws_loop(Socket, none, WsHandleLoopPid, SocketMode, WsAutoExit); ws_loop(Socket, none, WsHandleLoopPid, SocketMode, WsAutoExit);
handle_data(L, [255|T], Socket, WsHandleLoopPid, SocketMode, WsAutoExit) -> handle_data(L, [255|T], Socket, WsHandleLoopPid, SocketMode, WsAutoExit) ->
%?DEBUG("handle_data 3", []),
WsHandleLoopPid ! {browser, lists:reverse(L)}, WsHandleLoopPid ! {browser, lists:reverse(L)},
handle_data(none, T, Socket, WsHandleLoopPid, SocketMode, WsAutoExit); handle_data(none, T, Socket, WsHandleLoopPid, SocketMode, WsAutoExit);
handle_data(L, [H|T], Socket, WsHandleLoopPid, SocketMode, WsAutoExit) -> handle_data(L, [H|T], Socket, WsHandleLoopPid, SocketMode, WsAutoExit) ->
%?DEBUG("handle_data 4, Buffer = ~p", [L]),
handle_data([H|L], T, Socket, WsHandleLoopPid, SocketMode, WsAutoExit); handle_data([H|L], T, Socket, WsHandleLoopPid, SocketMode, WsAutoExit);
handle_data([], L, Socket, WsHandleLoopPid, SocketMode, WsAutoExit) -> handle_data([], L, Socket, WsHandleLoopPid, SocketMode, WsAutoExit) ->
%?DEBUG("handle_data 5", []),
ws_loop(Socket, L, WsHandleLoopPid, SocketMode, WsAutoExit). ws_loop(Socket, L, WsHandleLoopPid, SocketMode, WsAutoExit).
% Close socket and custom handling loop dependency % Close socket and custom handling loop dependency