1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 18:53:28 +01:00

logs.cpp: fix regression (#12995)

Fixes #12994
This commit is contained in:
Elad Ashkenazi 2022-11-29 21:56:18 +02:00 committed by GitHub
parent e9e139c364
commit 630edde10f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -497,7 +497,7 @@ int main(int argc, char** argv)
fs::device_stat stats{};
if (!fs::statfs(fs::get_cache_dir(), stats) || stats.avail_free < 128 * 1024 * 1024)
{
report_fatal_error(fmt::format("Not enough free space (%f KB)", stats.avail_free / 1000000.));
std::fprintf(stderr, "Not enough free space for logs (%f KB)", stats.avail_free / 1000000.);
}
// Limit log size to ~25% of free space

View File

@ -533,7 +533,7 @@ bool logs::file_writer::flush(u64 bufv)
const u64 read_pos = m_out;
const u64 out_index = read_pos % s_log_size;
const u64 pushed = (bufv / s_log_size) % s_log_size;
const u64 end = std::min<u64>(out_index < pushed ? read_pos - out_index + pushed : (read_pos + s_log_size) & ~(s_log_size - 1), m_max_size);
const u64 end = std::min<u64>(out_index <= pushed ? read_pos - out_index + pushed : ((read_pos + s_log_size) & ~(s_log_size - 1)), m_max_size);
if (end > read_pos)
{
@ -590,7 +590,7 @@ void logs::file_writer::log(const char* text, usz size)
const u64 v1 = (v / s_log_size) % s_log_size;
const u64 v2 = v % s_log_size;
if (v1 + v2 + size > (out < v1 ? out + s_log_size : out)) [[unlikely]]
if (v1 + v2 + size >= (out <= v1 ? out + s_log_size : out)) [[unlikely]]
{
return nullptr;
}
@ -644,13 +644,13 @@ void logs::file_writer::log(const char* text, usz size)
void logs::file_writer::sync()
{
if (!m_fptr || (!m_fout && !m_fout2))
if (!m_fptr)
{
return;
}
// Wait for the writer thread
while ((m_out % s_log_size) * s_log_size < m_buf)
while ((m_out % s_log_size) * s_log_size != m_buf % (s_log_size * s_log_size))
{
if (m_out >= m_max_size)
{