kopia lustrzana https://github.com/ryukoposting/Signal-Android
Remove SELF_LOCK from LiveRecipientCache.
Had the potential to deadlock if accessed inside of a database transaction.fork-5.53.8
rodzic
2be3068675
commit
4b3e7c8858
|
@ -9,6 +9,7 @@ import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import org.signal.core.util.concurrent.SignalExecutors;
|
import org.signal.core.util.concurrent.SignalExecutors;
|
||||||
import org.signal.core.util.logging.Log;
|
import org.signal.core.util.logging.Log;
|
||||||
|
import org.thoughtcrime.securesms.crypto.DatabaseSessionLock;
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||||
import org.thoughtcrime.securesms.database.RecipientDatabase;
|
import org.thoughtcrime.securesms.database.RecipientDatabase;
|
||||||
import org.thoughtcrime.securesms.database.RecipientDatabase.MissingRecipientException;
|
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.database.model.ThreadRecord;
|
||||||
import org.thoughtcrime.securesms.util.LRUCache;
|
import org.thoughtcrime.securesms.util.LRUCache;
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
|
import org.whispersystems.signalservice.api.SignalSessionLock;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -30,14 +32,11 @@ public final class LiveRecipientCache {
|
||||||
private static final int CACHE_MAX = 1000;
|
private static final int CACHE_MAX = 1000;
|
||||||
private static final int CACHE_WARM_MAX = 500;
|
private static final int CACHE_WARM_MAX = 500;
|
||||||
|
|
||||||
private static final Object SELF_LOCK = new Object();
|
|
||||||
|
|
||||||
private final Context context;
|
private final Context context;
|
||||||
private final RecipientDatabase recipientDatabase;
|
private final RecipientDatabase recipientDatabase;
|
||||||
private final Map<RecipientId, LiveRecipient> recipients;
|
private final Map<RecipientId, LiveRecipient> recipients;
|
||||||
private final LiveRecipient unknown;
|
private final LiveRecipient unknown;
|
||||||
|
|
||||||
@GuardedBy("SELF_LOCK")
|
|
||||||
private RecipientId localRecipientId;
|
private RecipientId localRecipientId;
|
||||||
private boolean warmedUp;
|
private boolean warmedUp;
|
||||||
|
|
||||||
|
@ -111,7 +110,7 @@ public final class LiveRecipientCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull Recipient getSelf() {
|
@NonNull Recipient getSelf() {
|
||||||
synchronized (SELF_LOCK) {
|
try (SignalSessionLock.Lock unused = DatabaseSessionLock.INSTANCE.acquire()) {
|
||||||
if (localRecipientId == null) {
|
if (localRecipientId == null) {
|
||||||
UUID localUuid = TextSecurePreferences.getLocalUuid(context);
|
UUID localUuid = TextSecurePreferences.getLocalUuid(context);
|
||||||
String localE164 = TextSecurePreferences.getLocalNumber(context);
|
String localE164 = TextSecurePreferences.getLocalNumber(context);
|
||||||
|
|
Ładowanie…
Reference in New Issue