aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/src/core
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2020-07-21 15:48:42 +0200
committerfiaxh <git@lightrise.org>2020-07-21 15:48:42 +0200
commitc887240fdcdbc8f76c6bdd37b1174b8154907c4c (patch)
tree889151d1947482a7da968c076b7bf8e09da91e8b /xmpp-vala/src/core
parent7309c6f3ac4e580f197b4835d05bb011fa90780b (diff)
downloaddino-c887240fdcdbc8f76c6bdd37b1174b8154907c4c.tar.gz
dino-c887240fdcdbc8f76c6bdd37b1174b8154907c4c.zip
Improve stream management queue
Diffstat (limited to 'xmpp-vala/src/core')
-rw-r--r--xmpp-vala/src/core/stanza_writer.vala3
-rw-r--r--xmpp-vala/src/core/xmpp_stream.vala6
2 files changed, 8 insertions, 1 deletions
diff --git a/xmpp-vala/src/core/stanza_writer.vala b/xmpp-vala/src/core/stanza_writer.vala
index 51f0061f..62fe022a 100644
--- a/xmpp-vala/src/core/stanza_writer.vala
+++ b/xmpp-vala/src/core/stanza_writer.vala
@@ -1,6 +1,8 @@
namespace Xmpp {
public class StanzaWriter {
+ public signal void cancel();
+
private OutputStream output;
private Queue<SourceFuncWrapper> queue = new Queue<SourceFuncWrapper>();
@@ -43,6 +45,7 @@ public class StanzaWriter {
try {
yield output.write_all_async(data, 0, null, null);
} catch (GLib.Error e) {
+ cancel();
throw new XmlError.IO(@"IOError in GLib: $(e.message)");
} finally {
SourceFuncWrapper? sfw = queue.pop_head();
diff --git a/xmpp-vala/src/core/xmpp_stream.vala b/xmpp-vala/src/core/xmpp_stream.vala
index 7e7588b1..ad4dae97 100644
--- a/xmpp-vala/src/core/xmpp_stream.vala
+++ b/xmpp-vala/src/core/xmpp_stream.vala
@@ -97,6 +97,8 @@ public class XmppStream {
this.stream = stream;
reader = new StanzaReader.for_stream(stream.input_stream);
writer = new StanzaWriter.for_stream(stream.output_stream);
+
+ writer.cancel.connect(reader.cancel);
require_setup();
}
@@ -123,7 +125,9 @@ public class XmppStream {
[Version (deprecated = true, deprecated_since = "0.1", replacement = "write_async")]
public void write(StanzaNode node) {
write_async.begin(node, (obj, res) => {
- write_async.end(res);
+ try {
+ write_async.end(res);
+ } catch (Error e) { }
});
}