aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2009-06-20 18:18:38 +0500
committerWaqas Hussain <waqas20@gmail.com>2009-06-20 18:18:38 +0500
commit0119d748022e9afcd03285870ae2c3985cb105d5 (patch)
tree2bf808d41dd9dccae94900bb0761e44e61779da6 /core
parent2753815a11b9964e0fa4d2eb4dcc4e0df3c701c0 (diff)
downloadprosody-0119d748022e9afcd03285870ae2c3985cb105d5.tar.gz
prosody-0119d748022e9afcd03285870ae2c3985cb105d5.zip
stanza_router: Skip prepping 'to' in many common cases - #optimization
Diffstat (limited to 'core')
-rw-r--r--core/stanza_router.lua22
1 files changed, 13 insertions, 9 deletions
diff --git a/core/stanza_router.lua b/core/stanza_router.lua
index 03035e8e..e5454119 100644
--- a/core/stanza_router.lua
+++ b/core/stanza_router.lua
@@ -66,17 +66,21 @@ function core_process_stanza(origin, stanza)
local from_node, from_host, from_resource;
local to_bare, from_bare;
if to then
- node, host, resource = jid_prepped_split(to);
- if not host then
- log("warn", "Received stanza with invalid destination JID: %s", to);
- if stanza.attr.type ~= "error" and stanza.attr.type ~= "result" then
- origin.send(st.error_reply(stanza, "modify", "jid-malformed", "The destination address is invalid: "..to));
+ if full_sessions[to] or bare_sessions[to] or hosts[to] then
+ node, host = jid_split(to); -- TODO only the host is needed, optimize
+ else
+ node, host, resource = jid_prepped_split(to);
+ if not host then
+ log("warn", "Received stanza with invalid destination JID: %s", to);
+ if stanza.attr.type ~= "error" and stanza.attr.type ~= "result" then
+ origin.send(st.error_reply(stanza, "modify", "jid-malformed", "The destination address is invalid: "..to));
+ end
+ return;
end
- return;
+ to_bare = node and (node.."@"..host) or host; -- bare JID
+ if resource then to = to_bare.."/"..resource; else to = to_bare; end
+ stanza.attr.to = to;
end
- to_bare = node and (node.."@"..host) or host; -- bare JID
- if resource then to = to_bare.."/"..resource; else to = to_bare; end
- stanza.attr.to = to;
end
if from and not origin.full_jid then
-- We only stamp the 'from' on c2s stanzas, so we still need to check validity