25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-28 16:34:13 +01:00

* src/eldap/eldap.erl: Close a connection on tcp_error.

SVN Revision: 1851
This commit is contained in:
Evgeniy Khramtsov 2009-01-23 07:28:49 +00:00
parent ee1140483c
commit e2fa195e20
2 changed files with 17 additions and 12 deletions

View File

@ -1,3 +1,7 @@
2009-01-23 Evgeniy Khramtsov <ekhramtsov@process-one.net>
* src/eldap/eldap.erl: Close a connection on tcp_error.
2009-01-23 Badlop <badlop@process-one.net> 2009-01-23 Badlop <badlop@process-one.net>
* src/odbc/mysql.sql: Fix complain about comment syntax * src/odbc/mysql.sql: Fix complain about comment syntax

View File

@ -517,22 +517,13 @@ handle_info({tcp, _Socket, Data}, StateName, S)
handle_info({tcp_closed, _Socket}, Fsm_state, S) -> handle_info({tcp_closed, _Socket}, Fsm_state, S) ->
?WARNING_MSG("LDAP server closed the connection: ~s:~p~nIn State: ~p", ?WARNING_MSG("LDAP server closed the connection: ~s:~p~nIn State: ~p",
[S#eldap.host, S#eldap.port ,Fsm_state]), [S#eldap.host, S#eldap.port ,Fsm_state]),
F = fun(_Id, [{Timer, From, _Name}|_]) -> {ok, NextState, NewS} = close_and_rebind(S, tcp_closed),
gen_fsm:reply(From, {error, tcp_closed}),
cancel_timer(Timer)
end,
dict:map(F, S#eldap.dict),
{ok, NextState, NewS} = connect_bind(S#eldap{fd = null,
dict = dict:new(),
bind_q=queue:new()}),
{next_state, NextState, NewS}; {next_state, NextState, NewS};
handle_info({tcp_error, _Socket, Reason}, Fsm_state, S) -> handle_info({tcp_error, _Socket, Reason}, Fsm_state, S) ->
?DEBUG("eldap received tcp_error: ~p~nIn State: ~p", [Reason, Fsm_state]), ?DEBUG("eldap received tcp_error: ~p~nIn State: ~p", [Reason, Fsm_state]),
%% XXX wouldn't it be safer to try reconnect ? {ok, NextState, NewS} = close_and_rebind(S, tcp_error),
%% if we were waiting a result, we may mait forever {next_state, NextState, NewS};
%% cause request is probably lost....
{next_state, Fsm_state, S};
%% %%
%% Timers %% Timers
@ -1006,3 +997,13 @@ bump_id(#eldap{id = Id}) when Id > ?MAX_TRANSACTION_ID ->
?MIN_TRANSACTION_ID; ?MIN_TRANSACTION_ID;
bump_id(#eldap{id = Id}) -> bump_id(#eldap{id = Id}) ->
Id + 1. Id + 1.
close_and_rebind(State, Err) ->
F = fun(_Id, [{Timer, From, _Name}|_]) ->
gen_fsm:reply(From, {error, Err}),
cancel_timer(Timer)
end,
dict:map(F, State#eldap.dict),
connect_bind(State#eldap{fd = null,
dict = dict:new(),
bind_q=queue:new()}).