Skip to content

Commit 5c447b7

Browse files
committed
fix to set valid reply when no calib task
1 parent 7fb48e4 commit 5c447b7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

examples/15-ODC.cxx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ void httpServer(tcp::acceptor& acceptor, tcp::socket& socket) {
9999
std::string calibTasksJson;
100100
const std::lock_guard<std::mutex> lock(gMapAccess);
101101
calibTasksJson += "[" + std::to_string(0);
102+
int countOk = 0;
102103
for (const auto& run : gStats) {
103104
if (run.second.TasksPerCalib.find(calib) != run.second.TasksPerCalib.end()) {
104105
calibTasksJson += ", \"";
@@ -113,9 +114,14 @@ void httpServer(tcp::acceptor& acceptor, tcp::socket& socket) {
113114
} else {
114115
calibTasksJson += ",0";
115116
}
117+
countOk++;
116118
}
117119
}
118120
calibTasksJson += "]";
121+
// workaround to set valid reply if nothing to report
122+
if (!countOk) {
123+
calibTasksJson = "[0, \"\", 0, 0]";
124+
}
119125
beast::ostream(response.body()) << jsonPrefix << calibTasksJson << jsonSuffix << '\n';
120126
});
121127
connection->start();

0 commit comments

Comments
 (0)