From e6e1d4aef4320957ba0856324e2f261ed9e679b0 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Wed, 9 Apr 2025 20:44:51 +0200 Subject: xmpp: Remove connection timeout before trying a new connection Fixes #1666 --- xmpp-vala/src/core/stream_connect.vala | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'xmpp-vala') 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; } -- cgit v1.3