mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 09:20:19 +01:00
Remove SELF_LOCK from LiveRecipientCache.
Had the potential to deadlock if accessed inside of a database transaction.
This commit is contained in:
committed by
Cody Henthorne
parent
2be3068675
commit
4b3e7c8858
@@ -9,6 +9,7 @@ import androidx.annotation.NonNull;
|
||||
|
||||
import org.signal.core.util.concurrent.SignalExecutors;
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.crypto.DatabaseSessionLock;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.MissingRecipientException;
|
||||
@@ -16,6 +17,7 @@ import org.thoughtcrime.securesms.database.ThreadDatabase;
|
||||
import org.thoughtcrime.securesms.database.model.ThreadRecord;
|
||||
import org.thoughtcrime.securesms.util.LRUCache;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.whispersystems.signalservice.api.SignalSessionLock;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -30,14 +32,11 @@ public final class LiveRecipientCache {
|
||||
private static final int CACHE_MAX = 1000;
|
||||
private static final int CACHE_WARM_MAX = 500;
|
||||
|
||||
private static final Object SELF_LOCK = new Object();
|
||||
|
||||
private final Context context;
|
||||
private final RecipientDatabase recipientDatabase;
|
||||
private final Map<RecipientId, LiveRecipient> recipients;
|
||||
private final LiveRecipient unknown;
|
||||
|
||||
@GuardedBy("SELF_LOCK")
|
||||
private RecipientId localRecipientId;
|
||||
private boolean warmedUp;
|
||||
|
||||
@@ -111,7 +110,7 @@ public final class LiveRecipientCache {
|
||||
}
|
||||
|
||||
@NonNull Recipient getSelf() {
|
||||
synchronized (SELF_LOCK) {
|
||||
try (SignalSessionLock.Lock unused = DatabaseSessionLock.INSTANCE.acquire()) {
|
||||
if (localRecipientId == null) {
|
||||
UUID localUuid = TextSecurePreferences.getLocalUuid(context);
|
||||
String localE164 = TextSecurePreferences.getLocalNumber(context);
|
||||
|
||||
Reference in New Issue
Block a user