Fix data race in multithreaded application
This commit fixes a data race condition discovered by the gcc thread sanitizer by also locking the associated mutex when reading the corresponding counter. Fixes #426
This commit is contained in:
parent
20febb522b
commit
1741df3b97
|
@ -275,7 +275,11 @@ _dbus_counter_adjust_unix_fd (DBusCounter *counter,
|
|||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -287,7 +291,11 @@ _dbus_counter_get_size_value (DBusCounter *counter)
|
|||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue