aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2018-12-30 13:35:01 +0100
committerfiaxh <git@lightrise.org>2019-01-02 15:59:56 +0100
commitfc1a9a5712b1f46bcd2390e798147f3855042b96 (patch)
treebba4779f4fbaa57e26cdfb7a71c3078a6df3d056 /xmpp-vala
parentcdd4c0b854fd4d27fa1d9bd941df03888301780a (diff)
downloaddino-fc1a9a5712b1f46bcd2390e798147f3855042b96.tar.gz
dino-fc1a9a5712b1f46bcd2390e798147f3855042b96.zip
Improve ping timeouts, add debug output for XmlErrors and ping timeouts
Diffstat (limited to 'xmpp-vala')
-rw-r--r--xmpp-vala/src/core/stanza_reader.vala59
1 files changed, 33 insertions, 26 deletions
diff --git a/xmpp-vala/src/core/stanza_reader.vala b/xmpp-vala/src/core/stanza_reader.vala
index b8cb1f4c..43c453ff 100644
--- a/xmpp-vala/src/core/stanza_reader.vala
+++ b/xmpp-vala/src/core/stanza_reader.vala
@@ -223,38 +223,45 @@ public class StanzaReader {
}
public async StanzaNode read_stanza_node() throws XmlError {
- ns_state = ns_state.push();
- var res = yield read_node_start();
- if (res.has_nodes) {
- bool finishNodeSeen = false;
- do {
- yield skip_until_non_ws();
- if ((yield peek_single()) == '<') {
- skip_single();
- if ((yield peek_single()) == '/') {
- skip_single();
- string desc = yield read_until_char('>');
+ try {
+ ns_state = ns_state.push();
+ var res = yield read_node_start();
+ if (res.has_nodes) {
+ bool finish_node_seen = false;
+ do {
+ yield skip_until_non_ws();
+ if ((yield peek_single()) == '<') {
skip_single();
- if (desc.contains(":")) {
- var split = desc.split(":");
- if (split[0] != ns_state.find_name((!)res.ns_uri)) throw new XmlError.BAD_XML("");
- if (split[1] != res.name) throw new XmlError.BAD_XML("");
+ if ((yield peek_single()) == '/') {
+ skip_single();
+ string desc = yield read_until_char('>');
+ skip_single();
+ if (desc.contains(":")) {
+ var split = desc.split(":");
+ if (split[0] != ns_state.find_name((!)res.ns_uri)) throw new XmlError.BAD_XML("");
+ if (split[1] != res.name) throw new XmlError.BAD_XML("");
+ } else {
+ if (ns_state.current_ns_uri != res.ns_uri) throw new XmlError.BAD_XML("");
+ if (desc != res.name) throw new XmlError.BAD_XML("");
+ }
+ finish_node_seen = true;
} else {
- if (ns_state.current_ns_uri != res.ns_uri) throw new XmlError.BAD_XML("");
- if (desc != res.name) throw new XmlError.BAD_XML("");
+ res.sub_nodes.add(yield read_stanza_node());
}
- finishNodeSeen = true;
} else {
- res.sub_nodes.add(yield read_stanza_node());
+ res.sub_nodes.add(yield read_text_node());
}
- } else {
- res.sub_nodes.add(yield read_text_node());
- }
- } while (!finishNodeSeen);
- if (res.sub_nodes.size == 0) res.has_nodes = false;
+ } while (!finish_node_seen);
+ if (res.sub_nodes.size == 0) res.has_nodes = false;
+ }
+ ns_state = ns_state.pop();
+ return res;
+ } catch (XmlError e) {
+ uint8[] buffer_cpy = buffer.copy();
+ buffer_cpy += '\0';
+ warning("XmlError at: %s".printf((string)buffer_cpy) + "\n");
+ throw e;
}
- ns_state = ns_state.pop();
- return res;
}
public async StanzaNode read_node() throws XmlError {