Permalink
Browse files

improved peer_addr getting and debug messages

  • Loading branch information...
ostinelli committed Dec 4, 2011
1 parent dce39c9 commit 6a4c9ea164ee46f25f24ed9289990f8aa1fc26b9
Showing with 8 additions and 4 deletions.
  1. +3 −1 src/misultin_http.erl
  2. +1 −1 src/misultin_sessions.erl
  3. +1 −1 src/misultin_utility.erl
  4. +3 −1 src/misultin_websocket.erl
View
@@ -616,10 +616,11 @@ socket_loop(#c{compress = Compress} = C, #req{socket = Sock, socket_mode = Socke
?LOG_DEBUG("received a session command: ~p", [SessionCmd]),
case misultin_utility:get_peer(Req#req.headers, Req#req.peer_addr) of
{error, Reason} ->
- ?LOG_ERROR("error getting remote peer_addr: ~p, cannot get/create session", [Reason]),
+ ?LOG_DEBUG("error getting remote peer_addr: ~p, cannot get/create session", [Reason]),
misultin_utility:respond(CallerPid, {error, {peer_addr, Reason}}),
socket_loop(C, Req, LoopPid, ReqOptions, AppHeaders, HttpCodeSent, SizeSent);
{ok, PeerAddr} ->
+ ?LOG_DEBUG("got remote peer_addr: ~p", [PeerAddr]),
case SessionCmd of
{session, Cookies} ->
% start new session process or retrieve exiting one's id
@@ -631,6 +632,7 @@ socket_loop(#c{compress = Compress} = C, #req{socket = Sock, socket_mode = Socke
socket_loop(C, Req, LoopPid, ReqOptions, [misultin_sessions:set_session_cookie(SessionId)|AppHeaders], HttpCodeSent, SizeSent);
{save_session_state, SessionId, SessionState} ->
% save session state
+ ?LOG_DEBUG("trying to save new session state: ~p", [SessionState]),
Response = misultin_sessions:save_session_state(C#c.sessions_ref, SessionId, SessionState, PeerAddr),
misultin_utility:respond(CallerPid, Response),
% loop
@@ -123,7 +123,7 @@ handle_call({session, undefined, PeerAddr, CreateIfNonExistant}, _From, #state{t
end;
handle_call({session, SessionId, PeerAddr, CreateIfNonExistant}, _From, #state{table_sessions = TableSessions, table_date_ref = TableDateRef} = State) ->
- ?LOG_DEBUG("starting or retrieving session ~p", [SessionId]),
+ ?LOG_DEBUG("retrieving session ~p, starting new if non-existant is ~p", [SessionId, CreateIfNonExistant]),
case ets:lookup(TableSessions, SessionId) of
[] when CreateIfNonExistant =:= true ->
?LOG_DEBUG("session with id ~p could not be found, start new one", [SessionId]),
View
@@ -529,7 +529,7 @@ get_peer(Headers, ConnectionPeerAddr) ->
end,
case Host of
undefined ->
- ConnectionPeerAddr;
+ {ok, ConnectionPeerAddr};
_ ->
case inet_parse:address(Host) of
{error, _Reason} ->
@@ -209,10 +209,11 @@ ws_loop(WsHandleLoopPid, SessionsRef, #ws{vsn = Vsn, socket = Socket, socket_mod
?LOG_DEBUG("received a session command: ~p", [SessionCmd]),
case misultin_utility:get_peer(Ws#ws.headers, Ws#ws.peer_addr) of
{error, Reason} ->
- ?LOG_ERROR("error getting remote peer_addr: ~p, cannot get session", [Reason]),
+ ?LOG_DEBUG("error getting remote peer_addr: ~p, cannot get session", [Reason]),
misultin_utility:respond(CallerPid, {error, {peer_addr, Reason}}),
ws_loop(WsHandleLoopPid, SessionsRef, Ws, State);
{ok, PeerAddr} ->
+ ?LOG_DEBUG("got remote peer_addr: ~p", [PeerAddr]),
case SessionCmd of
{session, Cookies} ->
% websocket cannot create sessions since they don't generate set-cookies
@@ -229,6 +230,7 @@ ws_loop(WsHandleLoopPid, SessionsRef, #ws{vsn = Vsn, socket = Socket, socket_mod
end;
{save_session_state, SessionId, SessionState} ->
% save session state
+ ?LOG_DEBUG("trying to save new session state: ~p", [SessionState]),
Response = misultin_sessions:save_session_state(SessionsRef, SessionId, SessionState, PeerAddr),
misultin_utility:respond(CallerPid, Response),
% loop

0 comments on commit 6a4c9ea

Please sign in to comment.