mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-23 12:38:33 +00:00
Fix pending retry receipt cache deadlock.
This commit is contained in:
@@ -23,10 +23,15 @@ class PendingRetryReceiptCache @VisibleForTesting constructor(
|
||||
fun insert(author: RecipientId, authorDevice: Int, sentTimestamp: Long, receivedTimestamp: Long, threadId: Long) {
|
||||
if (!FeatureFlags.retryReceipts()) return
|
||||
ensurePopulated()
|
||||
|
||||
val model: PendingRetryReceiptModel = database.insert(author, authorDevice, sentTimestamp, receivedTimestamp, threadId)
|
||||
synchronized(pendingRetries) {
|
||||
val model: PendingRetryReceiptModel = database.insert(author, authorDevice, sentTimestamp, receivedTimestamp, threadId)
|
||||
pendingRetries[RemoteMessageId(author, sentTimestamp)] = model
|
||||
val key = RemoteMessageId(author, sentTimestamp)
|
||||
val existing: PendingRetryReceiptModel? = pendingRetries[key]
|
||||
|
||||
// We rely on db unique constraint and auto-incrementing ids for conflict resolution here.
|
||||
if (existing == null || existing.id < model.id) {
|
||||
pendingRetries[key] = model
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,8 +59,8 @@ class PendingRetryReceiptCache @VisibleForTesting constructor(
|
||||
|
||||
synchronized(pendingRetries) {
|
||||
pendingRetries.remove(RemoteMessageId(model.author, model.sentTimestamp))
|
||||
database.delete(model)
|
||||
}
|
||||
database.delete(model)
|
||||
}
|
||||
|
||||
fun clear() {
|
||||
|
||||
Reference in New Issue
Block a user