Software /
code /
prosody
Comparison
plugins/mod_compression.lua @ 3226:69e920d7c968
mod_compression: Move logging of compression/decompression errors to before the closing of the stream, to make logs a bit easier to follow
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 10 Jun 2010 16:47:17 +0100 |
parent | 3223:ee2dabe699c9 |
child | 3301:772fb30b28fb |
comparison
equal
deleted
inserted
replaced
3224:9dd54a708523 | 3226:69e920d7c968 |
---|---|
96 -- setup compression for a stream | 96 -- setup compression for a stream |
97 local function setup_compression(session, deflate_stream) | 97 local function setup_compression(session, deflate_stream) |
98 add_filter(session, "bytes/out", function(t) | 98 add_filter(session, "bytes/out", function(t) |
99 local status, compressed, eof = pcall(deflate_stream, tostring(t), 'sync'); | 99 local status, compressed, eof = pcall(deflate_stream, tostring(t), 'sync'); |
100 if status == false then | 100 if status == false then |
101 module:log("warn", "%s", tostring(compressed)); | |
101 session:close({ | 102 session:close({ |
102 condition = "undefined-condition"; | 103 condition = "undefined-condition"; |
103 text = compressed; | 104 text = compressed; |
104 extra = st.stanza("failure", {xmlns="http://jabber.org/protocol/compress"}):tag("processing-failed"); | 105 extra = st.stanza("failure", {xmlns="http://jabber.org/protocol/compress"}):tag("processing-failed"); |
105 }); | 106 }); |
106 module:log("warn", "%s", tostring(compressed)); | |
107 return; | 107 return; |
108 end | 108 end |
109 return compressed; | 109 return compressed; |
110 end); | 110 end); |
111 end | 111 end |
113 -- setup decompression for a stream | 113 -- setup decompression for a stream |
114 local function setup_decompression(session, inflate_stream) | 114 local function setup_decompression(session, inflate_stream) |
115 add_filter(session, "bytes/in", function(data) | 115 add_filter(session, "bytes/in", function(data) |
116 local status, decompressed, eof = pcall(inflate_stream, data); | 116 local status, decompressed, eof = pcall(inflate_stream, data); |
117 if status == false then | 117 if status == false then |
118 module:log("warn", "%s", tostring(decompressed)); | |
118 session:close({ | 119 session:close({ |
119 condition = "undefined-condition"; | 120 condition = "undefined-condition"; |
120 text = decompressed; | 121 text = decompressed; |
121 extra = st.stanza("failure", {xmlns="http://jabber.org/protocol/compress"}):tag("processing-failed"); | 122 extra = st.stanza("failure", {xmlns="http://jabber.org/protocol/compress"}):tag("processing-failed"); |
122 }); | 123 }); |
123 module:log("warn", "%s", tostring(decompressed)); | |
124 return; | 124 return; |
125 end | 125 end |
126 return decompressed; | 126 return decompressed; |
127 end); | 127 end); |
128 end | 128 end |