diff --git a/server/stream_server.cpp b/server/stream_server.cpp index 5fe04516..f03a8343 100644 --- a/server/stream_server.cpp +++ b/server/stream_server.cpp @@ -722,11 +722,11 @@ void StreamServer::onMessageReceived(StreamSession* streamSession, const msg::Ba } -void StreamServer::saveConfig() +void StreamServer::saveConfig(const std::chrono::milliseconds& deferred) { config_timer_.cancel(); - config_timer_.expires_after(2s); - config_timer_.async_wait([this](const boost::system::error_code& ec) { + config_timer_.expires_after(deferred); + config_timer_.async_wait([](const boost::system::error_code& ec) { if (!ec) { LOG(DEBUG) << "Saving config\n"; diff --git a/server/stream_server.hpp b/server/stream_server.hpp index a8178215..c5414506 100644 --- a/server/stream_server.hpp +++ b/server/stream_server.hpp @@ -83,8 +83,9 @@ private: session_ptr getStreamSession(StreamSession* session) const; void ProcessRequest(const jsonrpcpp::request_ptr request, jsonrpcpp::entity_ptr& response, jsonrpcpp::notification_ptr& notification) const; void cleanup(); - /// save the server state deferred after 2s without a change to prevent blocking and too much disk io - void saveConfig(); + /// Save the server state deferred to prevent blocking and lower disk io + /// @param deferred the delay after the last call to saveConfig + void saveConfig(const std::chrono::milliseconds& deferred = std::chrono::seconds(2)); mutable std::recursive_mutex sessionsMutex_; mutable std::recursive_mutex clientMutex_;