From 43fc8b332954858efa3938e8e2ef0286b9853b9a Mon Sep 17 00:00:00 2001 From: Badlop Date: Fri, 21 Dec 2007 23:36:44 +0000 Subject: [PATCH] * src/mod_caps.erl: Bugfix in timeout checking. Check for timeout when an error response is received, and also before querying SVN Revision: 1095 --- ChangeLog | 5 +++++ src/mod_caps.erl | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index c725e5394..87f6e6f1c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-12-22 Badlop + + * src/mod_caps.erl: Bugfix in timeout checking. Check for timeout + when an error response is received, and also before querying + 2007-12-21 Badlop * src/ejabberd_ctl.erl: Added new command: mnesia (thanks to diff --git a/src/mod_caps.erl b/src/mod_caps.erl index a5ae8bbbc..d341677ee 100644 --- a/src/mod_caps.erl +++ b/src/mod_caps.erl @@ -146,6 +146,7 @@ handle_call({get_features, Caps}, From, State) -> {ok, Features} -> {reply, Features, State}; wait -> + gen_server:cast(self(), visit_feature_queries), Timeout = timestamp() + 10, FeatureQueries = State#state.feature_queries, NewFeatureQueries = [{From, Caps, Timeout} | FeatureQueries], @@ -221,6 +222,9 @@ handle_cast({disco_response, From, _To, error -> ?ERROR_MSG("ID '~s' matches no query", [ID]) end; + {error, _} -> + gen_server:cast(self(), visit_feature_queries), + ?ERROR_MSG("Error IQ reponse IQ from ~s: ~p", [jlib:jid_to_string(From), SubEls]); {result, _} -> ?ERROR_MSG("Invalid IQ contents from ~s: ~p", [jlib:jid_to_string(From), SubEls]); _ -> @@ -234,7 +238,7 @@ handle_cast(visit_feature_queries, #state{feature_queries = FeatureQueries} = St NewFeatureQueries = lists:foldl(fun({From, Caps, Timeout}, Acc) -> case maybe_get_features(Caps) of - wait when Timeout < Timestamp -> [{From, Caps, Timeout} | Acc]; + wait when Timeout > Timestamp -> [{From, Caps, Timeout} | Acc]; wait -> Acc; {ok, Features} -> gen_server:reply(From, Features),