aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/src
diff options
context:
space:
mode:
Diffstat (limited to 'xmpp-vala/src')
-rw-r--r--xmpp-vala/src/core/stream_connect.vala8
1 files changed, 7 insertions, 1 deletions
diff --git a/xmpp-vala/src/core/stream_connect.vala b/xmpp-vala/src/core/stream_connect.vala
index 17d47f38..ddf550e1 100644
--- a/xmpp-vala/src/core/stream_connect.vala
+++ b/xmpp-vala/src/core/stream_connect.vala
@@ -56,6 +56,7 @@ namespace Xmpp {
TlsXmppStream? stream = null;
TlsCertificateFlags? tls_errors = null;
IOError? io_error = null;
+ uint connection_timeout_id = 0;
foreach (SrvTargetInfo target in targets) {
try {
if (target.service == "xmpp-client") {
@@ -69,7 +70,7 @@ namespace Xmpp {
stream.add_module(module);
}
- uint connection_timeout_id = Timeout.add_seconds(30, () => {
+ connection_timeout_id = Timeout.add_seconds(30, () => {
warning("Connection attempt timed out");
stream.disconnect();
return Source.REMOVE;
@@ -78,12 +79,17 @@ namespace Xmpp {
yield stream.connect();
Source.remove(connection_timeout_id);
+ connection_timeout_id = 0;
return new XmppStreamResult() { stream=stream };
} catch (IOError e) {
warning("Could not establish XMPP session with %s:%i: %s", target.host, target.port, e.message);
if (stream != null) {
+ if (connection_timeout_id != 0) {
+ Source.remove(connection_timeout_id);
+ connection_timeout_id = 0;
+ }
if (stream.errors != null) {
tls_errors = stream.errors;
}