diff options
author | hrxi <hrrrxi@gmail.com> | 2019-08-08 17:12:02 +0200 |
---|---|---|
committer | hrxi <hrrrxi@gmail.com> | 2019-08-08 17:15:37 +0200 |
commit | 6494d7a45dabd180767890a310886146d83ae3be (patch) | |
tree | 6707217d24c1fdcb7265e8e4496a0adc7ac0ab27 /xmpp-vala/src/module/xep/0166_jingle.vala | |
parent | 9a1e9864d6ea5bc967a69b2245ead55ba7c05812 (diff) | |
download | dino-6494d7a45dabd180767890a310886146d83ae3be.tar.gz dino-6494d7a45dabd180767890a310886146d83ae3be.zip |
Fix race condition involving `session-terminate`
The Jingle file transfer (XEP-0234) specifies that the receiver of the
file transfer is the one to terminate the session. Otherwise, there
might be a race condition between the XMPP stream and out-of-band SOCKS5
connections.
Diffstat (limited to 'xmpp-vala/src/module/xep/0166_jingle.vala')
-rw-r--r-- | xmpp-vala/src/module/xep/0166_jingle.vala | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/xmpp-vala/src/module/xep/0166_jingle.vala b/xmpp-vala/src/module/xep/0166_jingle.vala index f5d112aa..2e38b164 100644 --- a/xmpp-vala/src/module/xep/0166_jingle.vala +++ b/xmpp-vala/src/module/xep/0166_jingle.vala @@ -397,6 +397,8 @@ public class Session { private Connection connection; public IOStream conn { get { return connection; } } + public bool terminate_on_connection_close { get; set; } + // INITIATE_SENT | INITIATE_RECEIVED | CONNECTING Set<string> tried_transport_methods = new HashSet<string>(); TransportParameters? transport = null; @@ -417,6 +419,7 @@ public class Session { this.transport = transport; this.connection = new Connection(this); this.session_terminate_handler = (owned)session_terminate_handler; + this.terminate_on_connection_close = true; } public Session.initiate_received(string sid, TransportType type, TransportParameters? transport, Jid local_full_jid, Jid peer_full_jid, string content_name, owned SessionTerminate session_terminate_handler) { @@ -435,6 +438,7 @@ public class Session { } this.connection = new Connection(this); this.session_terminate_handler = (owned)session_terminate_handler; + this.terminate_on_connection_close = true; } public void handle_iq_set(XmppStream stream, string action, StanzaNode jingle, Iq.Stanza iq) throws IqError { @@ -719,9 +723,11 @@ public class Session { terminate(reason, "transport error: $(error.message)"); } public void on_connection_close() { - StanzaNode reason = new StanzaNode.build("reason", NS_URI) - .put_node(new StanzaNode.build("success", NS_URI)); - terminate(reason, "success"); + if (terminate_on_connection_close) { + StanzaNode reason = new StanzaNode.build("reason", NS_URI) + .put_node(new StanzaNode.build("success", NS_URI)); + terminate(reason, "success"); + } } public void terminate(StanzaNode reason, string? local_reason) { |