Created
August 7, 2014 19:56
-
-
Save daurnimator/f0df8c1d5430fd8cd9e9 to your computer and use it in GitHub Desktop.
Patch to prosody's xmppstream to allow stream pipelining
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -r 93b8438fe761 util/xmppstream.lua | |
--- a/util/xmppstream.lua Thu Aug 07 12:35:12 2014 -0400 | |
+++ b/util/xmppstream.lua Thu Aug 07 15:55:16 2014 -0400 | |
@@ -227,6 +227,7 @@ | |
function new(session, stream_callbacks, stanza_size_limit) | |
-- Used to track parser progress (e.g. to enforce size limits) | |
local n_outstanding_bytes = 0; | |
+ local current_data | |
local handle_progress; | |
if lxp_supports_bytecount then | |
function handle_progress(n_parsed_bytes) | |
@@ -261,17 +262,27 @@ | |
end | |
return { | |
- reset = function () | |
+ reset = function (self) | |
+ parser:stop(); | |
parser = new_parser(handlers, ns_separator, false); | |
parse = parser.parse; | |
n_outstanding_bytes = 0; | |
meta.reset(); | |
+ if lxp_supports_bytecount then | |
+ local leftover = current_data:sub(-n_outstanding_bytes); | |
+ self:feed(leftover); | |
+ end | |
end, | |
feed = function (self, data) | |
if lxp_supports_bytecount then | |
n_outstanding_bytes = n_outstanding_bytes + #data; | |
end | |
+ current_data = data; | |
+ local this_parser = parser; | |
local ok, err = parse(parser, data); | |
+ if parser == this_parser then -- Don't want to do this there was a reset. | |
+ current_data = nil; | |
+ end | |
if lxp_supports_bytecount and n_outstanding_bytes > stanza_size_limit then | |
return nil, "stanza-too-large"; | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment