diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e4a95e5..552f3d76 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,7 +31,7 @@ endif() # Define project project(Monitoring - VERSION 3.19.2 + VERSION 3.19.3 DESCRIPTION "O2 Monitoring library" LANGUAGES CXX ) diff --git a/examples/15-ODC.cxx b/examples/15-ODC.cxx index f6c0cca0..3118f37b 100644 --- a/examples/15-ODC.cxx +++ b/examples/15-ODC.cxx @@ -99,6 +99,7 @@ void httpServer(tcp::acceptor& acceptor, tcp::socket& socket) { std::string calibTasksJson; const std::lock_guard lock(gMapAccess); calibTasksJson += "[" + std::to_string(0); + int countOk = 0; for (const auto& run : gStats) { if (run.second.TasksPerCalib.find(calib) != run.second.TasksPerCalib.end()) { calibTasksJson += ", \""; @@ -113,9 +114,14 @@ void httpServer(tcp::acceptor& acceptor, tcp::socket& socket) { } else { calibTasksJson += ",0"; } + countOk++; } } calibTasksJson += "]"; + // workaround to set valid reply if nothing to report + if (!countOk) { + calibTasksJson = "[0, \"\", 0, 0]"; + } beast::ostream(response.body()) << jsonPrefix << calibTasksJson << jsonSuffix << '\n'; }); connection->start();