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:
parent
2c955a2a18
commit
50d3ab6bba
|
@ -1,6 +1,6 @@
|
|||
cmake_minimum_required (VERSION 3.7)
|
||||
project (expandurl-mastodon
|
||||
VERSION 0.8.0
|
||||
VERSION 0.8.1
|
||||
LANGUAGES CXX
|
||||
)
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user