mirror of
https://gitlab.com/mishakmak/pam-fprint-grosshack.git
synced 2026-04-08 20:03:34 +02:00
device: Add a memory barrier when getting session pointer
The test suite ran into a very rare error where it seemed to get stuck during authorization. A possible explanation is that the priv->_session pointer re-fetching is optimized away and the pointer just continues to contain the invalid placeholder rather than an updated value. Use g_atomic_pointer_get in order to avoid this possibility entirely.
This commit is contained in:
committed by
Marco Trevisan
parent
2dd1cd8fc3
commit
161278cacd
@ -168,7 +168,7 @@ session_data_get (FprintDevicePrivate *priv)
|
||||
/* Get the current pointer and mark the pointer as "busy". */
|
||||
do
|
||||
{
|
||||
cur = priv->_session;
|
||||
cur = g_atomic_pointer_get (&priv->_session);
|
||||
/* Swap if cur is valid, otherwise busy loop. */
|
||||
}
|
||||
while (cur == invalid || !g_atomic_pointer_compare_and_exchange (&priv->_session, cur, invalid));
|
||||
@ -205,7 +205,7 @@ session_data_set_new (FprintDevicePrivate *priv, gchar *sender, gchar *username)
|
||||
/* Get the current (but not if it is busy) and put the new one in place. */
|
||||
do
|
||||
{
|
||||
old = priv->_session;
|
||||
old = g_atomic_pointer_get (&priv->_session);
|
||||
/* Swap if old is valid, otherwise busy loop as someone is ref'ing it currently. */
|
||||
}
|
||||
while (old == invalid || !g_atomic_pointer_compare_and_exchange (&priv->_session, old, new));
|
||||
|
||||
Reference in New Issue
Block a user