aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2019-03-24 08:18:19 +0000
committerKim Alvefur <zash@zash.se>2019-03-24 08:18:19 +0000
commit3277b108c4f1b772e265d270c52ca2e5c9956879 (patch)
treec72f82595364871f9f685c183b084603bb5c90ca
parentff3904d881514abc83443b02e10cd621873bed64 (diff)
downloadprosody-3277b108c4f1b772e265d270c52ca2e5c9956879.tar.gz
prosody-3277b108c4f1b772e265d270c52ca2e5c9956879.zip
sessionmanager: Split byte-level sending into separate session.rawsend
-rw-r--r--core/sessionmanager.lua22
1 files changed, 14 insertions, 8 deletions
diff --git a/core/sessionmanager.lua b/core/sessionmanager.lua
index 2843001a..9a2456f2 100644
--- a/core/sessionmanager.lua
+++ b/core/sessionmanager.lua
@@ -32,20 +32,26 @@ local function new_session(conn)
local session = { conn = conn, type = "c2s_unauthed", conntime = gettime() };
local filter = initialize_filters(session);
local w = conn.write;
+
+ function session.rawsend(t)
+ t = filter("bytes/out", tostring(t));
+ if t then
+ local ret, err = w(conn, t);
+ if not ret then
+ session.log("debug", "Error writing to connection: %s", tostring(err));
+ return false, err;
+ end
+ end
+ return true;
+ end
+
session.send = function (t)
session.log("debug", "Sending[%s]: %s", session.type, t.top_tag and t:top_tag() or t:match("^[^>]*>?"));
if t.name then
t = filter("stanzas/out", t);
end
if t then
- t = filter("bytes/out", tostring(t));
- if t then
- local ret, err = w(conn, t);
- if not ret then
- session.log("debug", "Error writing to connection: %s", tostring(err));
- return false, err;
- end
- end
+ return session.rawsend(t);
end
return true;
end