Fixed reconnect issues, hopefully

Make the main thread sleep when the stream thread sleeps due to a connection error.
This should solve the problem of having multiple stream threads running doing too many connection attempts
This commit is contained in:
tastytea 2018-05-28 13:23:16 +02:00
parent 2c955a2a18
commit 50d3ab6bba
Signed by: tastytea
GPG Key ID: 59346E0EA35C67E5
3 changed files with 9 additions and 2 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required (VERSION 3.7)
project (expandurl-mastodon
VERSION 0.8.0
VERSION 0.8.1
LANGUAGES CXX
)

View File

@ -75,7 +75,6 @@ int main(int argc, char *argv[])
listener.stop();
syslog(LOG_DEBUG, "Reestablishing connection...");
listener.start();
syslog(LOG_NOTICE, "Reestablished connection.");
new_messages = listener.catchup();
}

View File

@ -112,6 +112,10 @@ const void Listener::start()
{
syslog(LOG_NOTICE, "Connected to %s", _instance.c_str());
}
else if (ret != 14)
{ // If the stream thread sleeps, the main thread should sleep too
std::this_thread::sleep_for(std::chrono::seconds(60));
}
}
const void Listener::stop()
@ -192,6 +196,10 @@ const std::vector<Easy::Notification> Listener::catchup()
v.push_back(Easy::Notification(str));
}
}
else
{
syslog(LOG_ERR, "Could not catch up: Error %u", ret);
}
}
return v;