diff options
| author | Marvin W <git@larma.de> | 2025-04-09 20:44:51 +0200 |
|---|---|---|
| committer | Marvin W <git@larma.de> | 2025-04-09 20:44:51 +0200 |
| commit | e6e1d4aef4320957ba0856324e2f261ed9e679b0 (patch) | |
| tree | bba69f3ff877bedab7e43a7486ed2423057278c8 /xmpp-vala/src | |
| parent | 50eeb2f16dfa4342d50086404da068f5426cbe3c (diff) | |
xmpp: Remove connection timeout before trying a new connection
Fixes #1666
Diffstat (limited to 'xmpp-vala/src')
| -rw-r--r-- | xmpp-vala/src/core/stream_connect.vala | 8 |
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; } |
