mirror of
https://github.com/processone/ejabberd.git
synced 2024-06-02 21:17:12 +02:00
Cache caps timestamp before the IQ-request is done
This commit is contained in:
parent
b1e2538488
commit
deb87f2dfa
|
@ -375,6 +375,10 @@ feature_request(Host, From, Caps, [SubNode | Tail] = SubNodes) ->
|
||||||
[{"xmlns", ?NS_DISCO_INFO},
|
[{"xmlns", ?NS_DISCO_INFO},
|
||||||
{"node", Node ++ "#" ++ SubNode}],
|
{"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) ->
|
F = fun(IQReply) ->
|
||||||
feature_response(
|
feature_response(
|
||||||
IQReply, Host, From, Caps, SubNodes)
|
IQReply, Host, From, Caps, SubNodes)
|
||||||
|
@ -405,19 +409,11 @@ feature_response(#iq{type = result,
|
||||||
caps_features, BinaryNode, BinaryFeatures,
|
caps_features, BinaryNode, BinaryFeatures,
|
||||||
caps_write_fun(BinaryNode, BinaryFeatures));
|
caps_write_fun(BinaryNode, BinaryFeatures));
|
||||||
false ->
|
false ->
|
||||||
%% We cache current timestamp and will probe the client
|
ok
|
||||||
%% after BAD_HASH_LIFETIME seconds.
|
|
||||||
cache_tab:insert(caps_features, BinaryNode, now_ts(),
|
|
||||||
caps_write_fun(BinaryNode, now_ts()))
|
|
||||||
end,
|
end,
|
||||||
feature_request(Host, From, Caps, SubNodes);
|
feature_request(Host, From, Caps, SubNodes);
|
||||||
feature_response(_IQResult, Host, From, Caps, [SubNode | SubNodes]) ->
|
feature_response(_IQResult, Host, From, Caps, [_SubNode | SubNodes]) ->
|
||||||
%% We got type=error or invalid type=result stanza or timeout,
|
%% 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_request(Host, From, Caps, SubNodes).
|
feature_request(Host, From, Caps, SubNodes).
|
||||||
|
|
||||||
node_to_binary(Node, SubNode) ->
|
node_to_binary(Node, SubNode) ->
|
||||||
|
|
Loading…
Reference in New Issue
Block a user