summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2014-03-24 20:39:59 +0100
committerFlorent Le Coz <louiz@louiz.org>2014-03-24 20:39:59 +0100
commitcdc3183d9eb234feb2e8ca3d3019b78cce73bcf6 (patch)
treea17a8f1068b4a101390cc6cd0de95067ae3588a9 /src
parentffc820e234ebba39a0f04607f9a0fb044fe31b73 (diff)
downloadbiboumi-cdc3183d9eb234feb2e8ca3d3019b78cce73bcf6.tar.gz
biboumi-cdc3183d9eb234feb2e8ca3d3019b78cce73bcf6.tar.bz2
biboumi-cdc3183d9eb234feb2e8ca3d3019b78cce73bcf6.tar.xz
biboumi-cdc3183d9eb234feb2e8ca3d3019b78cce73bcf6.zip
Introduce two new bool, to know if the xmpp component should try to reconnect
If we never succeeded our connection+auth process, means we should probably not attempt any-more, and just give up. If we ever did, this means a reconnect is a good idea
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp3
-rw-r--r--src/xmpp/xmpp_component.cpp5
-rw-r--r--src/xmpp/xmpp_component.hpp9
3 files changed, 16 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp
index d40c457..6cba134 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -118,7 +118,8 @@ int main(int ac, char** av)
// happened because we sent something invalid to it and it decided to
// close the connection. This is a bug that should be fixed, but we
// still reconnect automatically instead of dropping everything
- if (!exiting && !xmpp_component->is_connected() &&
+ if (!exiting && xmpp_component->ever_auth &&
+ !xmpp_component->is_connected() &&
!xmpp_component->is_connecting())
{
xmpp_component->reset();
diff --git a/src/xmpp/xmpp_component.cpp b/src/xmpp/xmpp_component.cpp
index 5400535..d083190 100644
--- a/src/xmpp/xmpp_component.cpp
+++ b/src/xmpp/xmpp_component.cpp
@@ -24,6 +24,8 @@
#define STREAMS_NS "urn:ietf:params:xml:ns:xmpp-streams"
XmppComponent::XmppComponent(const std::string& hostname, const std::string& secret):
+ ever_auth(false),
+ last_auth(false),
served_hostname(hostname),
secret(secret),
authenticated(false),
@@ -144,6 +146,7 @@ void XmppComponent::on_remote_stream_open(const XmlNode& node)
return ;
}
+ this->last_auth = false;
// Try to authenticate
char digest[HASH_LENGTH * 2 + 1];
sha1nfo sha1;
@@ -212,6 +215,8 @@ void XmppComponent::handle_handshake(const Stanza& stanza)
{
(void)stanza;
this->authenticated = true;
+ this->ever_auth = true;
+ this->last_auth = true;
log_info("Authenticated with the XMPP server");
}
diff --git a/src/xmpp/xmpp_component.hpp b/src/xmpp/xmpp_component.hpp
index 3e401e5..373104c 100644
--- a/src/xmpp/xmpp_component.hpp
+++ b/src/xmpp/xmpp_component.hpp
@@ -140,6 +140,15 @@ public:
void handle_iq(const Stanza& stanza);
void handle_error(const Stanza& stanza);
+ /**
+ * Whether or not we ever succeeded our authentication to the XMPP server
+ */
+ bool ever_auth;
+ /**
+ * Whether or not the last connection+auth attempt was successful
+ */
+ bool last_auth;
+
private:
/**
* Return the bridge associated with the given full JID. Create a new one