Fix deadlock
This commit is contained in:
parent
3e5546ab78
commit
14fbce0880
|
@ -82,10 +82,13 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
return (preKeyRecord != nil);
|
||||
}
|
||||
|
||||
- (void)removePreKey:(int)preKeyId
|
||||
- (void)removePreKey:(int)preKeyId protocolContext:(nullable id)protocolContext
|
||||
{
|
||||
[self.dbReadWriteConnection removeObjectForKey:[self keyFromInt:preKeyId]
|
||||
inCollection:OWSPrimaryStoragePreKeyStoreCollection];
|
||||
if ([protocolContext isKindOfClass:YapDatabaseReadWriteTransaction.class]) {
|
||||
[(YapDatabaseReadWriteTransaction *)protocolContext removeObjectForKey:[self keyFromInt:preKeyId] inCollection:OWSPrimaryStoragePreKeyStoreCollection];
|
||||
} else {
|
||||
[self.dbReadWriteConnection removeObjectForKey:[self keyFromInt:preKeyId] inCollection:OWSPrimaryStoragePreKeyStoreCollection];
|
||||
}
|
||||
}
|
||||
|
||||
- (int)nextPreKeyId:(int)batchSize
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
PreKeyRecord *lastPreKeyRecord = [generatedKeys lastObject];
|
||||
PreKeyRecord *firstPreKeyRecord = [generatedKeys firstObject];
|
||||
|
||||
[[OWSPrimaryStorage sharedManager] removePreKey:lastPreKeyRecord.Id];
|
||||
[[OWSPrimaryStorage sharedManager] removePreKey:lastPreKeyRecord.Id protocolContext:nil];
|
||||
|
||||
XCTAssertThrows([[OWSPrimaryStorage sharedManager] throws_loadPreKey:lastPreKeyRecord.Id]);
|
||||
XCTAssertNoThrow([[OWSPrimaryStorage sharedManager] throws_loadPreKey:firstPreKeyRecord.Id]);
|
||||
|
|
Loading…
Reference in New Issue