ApiListener#ReplayLog(): stop reading files ASAP on send error

This commit is contained in:
Alexander A. Klimov 2024-02-09 14:44:52 +01:00 committed by Yonas Habteab
parent b538ad2528
commit f074e24d2a
1 changed files with 12 additions and 7 deletions

View File

@ -1462,7 +1462,9 @@ void ApiListener::ReplayLog(const JsonRpcConnection::Ptr& client)
return;
}
for (;;) {
bool stopReplay = false;
do {
std::unique_lock<std::mutex> lock(m_LogLock);
CloseLogFile();
@ -1545,6 +1547,7 @@ void ApiListener::ReplayLog(const JsonRpcConnection::Ptr& client)
Log(LogDebug, "ApiListener")
<< "Error while replaying log for endpoint '" << endpoint->GetName() << "': " << DiagnosticInformation(ex);
stopReplay = true;
break;
}
@ -1566,6 +1569,10 @@ void ApiListener::ReplayLog(const JsonRpcConnection::Ptr& client)
}
logStream->Close();
if (stopReplay) {
break;
}
}
if (count > 0) {
@ -1578,16 +1585,14 @@ void ApiListener::ReplayLog(const JsonRpcConnection::Ptr& client)
}
if (last_sync) {
{
ObjectLock olock2(endpoint);
endpoint->SetSyncing(false);
}
OpenLogFile();
break;
}
}
} while (!stopReplay);
ObjectLock olock2 (endpoint);
endpoint->SetSyncing(false);
}
void ApiListener::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata)