aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>2012-02-28 16:38:24 +1000
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>2012-02-28 16:38:24 +1000
commitdeb87f2dfa918dc79ff63846374a497edee036f2 (patch)
tree759c469407f21499f5a7ff8eca37cc8310812341 /src
parentUpdate copyright dates (diff)
Cache caps timestamp before the IQ-request is done
Diffstat (limited to 'src')
-rw-r--r--src/mod_caps.erl18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/mod_caps.erl b/src/mod_caps.erl
index efad3f16c..ba934e758 100644
--- a/src/mod_caps.erl
+++ b/src/mod_caps.erl
@@ -375,6 +375,10 @@ feature_request(Host, From, Caps, [SubNode | Tail] = SubNodes) ->
[{"xmlns", ?NS_DISCO_INFO},
{"node", Node ++ "#" ++ SubNode}],
[]}]},
+ %% We cache current timestamp in order to avoid
+ %% caps requests flood
+ cache_tab:insert(caps_features, BinaryNode, now_ts(),
+ caps_write_fun(BinaryNode, now_ts())),
F = fun(IQReply) ->
feature_response(
IQReply, Host, From, Caps, SubNodes)
@@ -405,19 +409,11 @@ feature_response(#iq{type = result,
caps_features, BinaryNode, BinaryFeatures,
caps_write_fun(BinaryNode, BinaryFeatures));
false ->
- %% We cache current timestamp and will probe the client
- %% after BAD_HASH_LIFETIME seconds.
- cache_tab:insert(caps_features, BinaryNode, now_ts(),
- caps_write_fun(BinaryNode, now_ts()))
+ ok
end,
feature_request(Host, From, Caps, SubNodes);
-feature_response(_IQResult, Host, From, Caps, [SubNode | SubNodes]) ->
- %% We got type=error or invalid type=result stanza or timeout,
- %% so we cache current timestamp and will probe the client
- %% after BAD_HASH_LIFETIME seconds.
- BinaryNode = node_to_binary(Caps#caps.node, SubNode),
- cache_tab:insert(caps_features, BinaryNode, now_ts(),
- caps_write_fun(BinaryNode, now_ts())),
+feature_response(_IQResult, Host, From, Caps, [_SubNode | SubNodes]) ->
+ %% We got type=error or invalid type=result stanza or timeout.
feature_request(Host, From, Caps, SubNodes).
node_to_binary(Node, SubNode) ->