mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-23 04:54:18 +00:00
Fix potential data race
This case could be considered benign however it could still be an undefined behavior to the compiler, so remove it. Ref: https://hacks.mozilla.org/2021/04/eliminating-data-races-in-firefox-a-technical-report/
This commit is contained in:
parent
05e3e46f5a
commit
a82ca6adb2
@ -184,9 +184,8 @@ SettingsStorage *SettingsStorage::instance()
|
|||||||
|
|
||||||
bool SettingsStorage::save()
|
bool SettingsStorage::save()
|
||||||
{
|
{
|
||||||
if (!m_dirty) return true; // Obtaining the lock is expensive, let's check early
|
const QWriteLocker locker(&m_lock); // guard for `m_dirty` too
|
||||||
const QWriteLocker locker(&m_lock); // to guard for `m_dirty`
|
if (!m_dirty) return true;
|
||||||
if (!m_dirty) return true; // something might have changed while we were getting the lock
|
|
||||||
|
|
||||||
const TransactionalSettings settings(QLatin1String("qBittorrent"));
|
const TransactionalSettings settings(QLatin1String("qBittorrent"));
|
||||||
if (!settings.write(m_data))
|
if (!settings.write(m_data))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user