diff options
Diffstat (limited to 'whiteboard.cpp')
-rw-r--r-- | whiteboard.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/whiteboard.cpp b/whiteboard.cpp index 044321b..5424a79 100644 --- a/whiteboard.cpp +++ b/whiteboard.cpp @@ -448,6 +448,16 @@ void Whiteboard::on_accept(boost::system::error_code ec, boost::asio::ip::tcp::s do_accept(); } +// for long running connections, don't timeout them but touch associated ids +// regularly, at cleanup time +void Whiteboard::touch_all_connections() +{ + std::for_each(m_registry.begin(), m_registry.end(), [&](const std::pair<ConnectionRegistry::connection, std::string>& i) + { + m_storage->touchDocument(i.second); + }); +} + // the actual main() for testability int Whiteboard::run(int argc, char* argv[]) { @@ -502,6 +512,7 @@ int Whiteboard::run(int argc, char* argv[]) std::lock_guard<std::mutex> lock(m_storage_mutex); if (!m_storage) throw std::runtime_error("Storage not initialized"); + touch_all_connections(); m_storage->cleanup(); storage_cleanup_timer.expires_at(storage_cleanup_timer.expires_at() + boost::asio::chrono::hours(24)); storage_cleanup_timer.async_wait(storage_cleanup_callback); |