This commit fixes a data race condition discovered by the
gcc thread sanitizer by also locking the associated mutex
when reading the corresponding counter.
Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/426
Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
(cherry picked from commit
1741df3b977001aee6bee7c7458ed786c60c8eb7)
long
_dbus_counter_get_size_value (DBusCounter *counter)
{
- return counter->size_value;
+ long result;
+ _dbus_rmutex_lock (counter->mutex);
+ result = counter->size_value;
+ _dbus_rmutex_unlock (counter->mutex);
+ return result;
}
/**
long
_dbus_counter_get_unix_fd_value (DBusCounter *counter)
{
- return counter->unix_fd_value;
+ long result;
+ _dbus_rmutex_lock (counter->mutex);
+ result = counter->unix_fd_value;
+ _dbus_rmutex_unlock (counter->mutex);
+ return result;
}
/**