Fix operations not being de-alloced

pull/1/head
Michael Kirk 7 years ago
parent 619597cd61
commit 39b691b697

@ -90,16 +90,21 @@ static const NSUInteger kMaxPrekeyUpdateFailureCount = 5;
} }
SSKRefreshPreKeysOperation *refreshOperation = [SSKRefreshPreKeysOperation new]; SSKRefreshPreKeysOperation *refreshOperation = [SSKRefreshPreKeysOperation new];
__weak SSKRefreshPreKeysOperation *weakRefreshOperation = refreshOperation;
NSBlockOperation *checkIfRefreshNecessaryOperation = [NSBlockOperation blockOperationWithBlock:^{ NSBlockOperation *checkIfRefreshNecessaryOperation = [NSBlockOperation blockOperationWithBlock:^{
BOOL shouldCheck = (lastPreKeyCheckTimestamp == nil BOOL shouldCheck = (lastPreKeyCheckTimestamp == nil
|| fabs([lastPreKeyCheckTimestamp timeIntervalSinceNow]) >= kPreKeyCheckFrequencySeconds); || fabs([lastPreKeyCheckTimestamp timeIntervalSinceNow]) >= kPreKeyCheckFrequencySeconds);
if (!shouldCheck) { if (!shouldCheck) {
[refreshOperation cancel]; [weakRefreshOperation cancel];
} }
}]; }];
[refreshOperation addDependency:checkIfRefreshNecessaryOperation]; [refreshOperation addDependency:checkIfRefreshNecessaryOperation];
SSKRotateSignedPreKeyOperation *rotationOperation = [SSKRotateSignedPreKeyOperation new]; SSKRotateSignedPreKeyOperation *rotationOperation = [SSKRotateSignedPreKeyOperation new];
__weak SSKRotateSignedPreKeyOperation *weakRotationOperation = rotationOperation;
NSBlockOperation *checkIfRotationNecessaryOperation = [NSBlockOperation blockOperationWithBlock:^{ NSBlockOperation *checkIfRotationNecessaryOperation = [NSBlockOperation blockOperationWithBlock:^{
OWSPrimaryStorage *primaryStorage = [OWSPrimaryStorage sharedManager]; OWSPrimaryStorage *primaryStorage = [OWSPrimaryStorage sharedManager];
SignedPreKeyRecord *_Nullable signedPreKey = [primaryStorage currentSignedPreKey]; SignedPreKeyRecord *_Nullable signedPreKey = [primaryStorage currentSignedPreKey];
@ -107,9 +112,10 @@ static const NSUInteger kMaxPrekeyUpdateFailureCount = 5;
BOOL shouldCheck BOOL shouldCheck
= !signedPreKey || fabs(signedPreKey.generatedAt.timeIntervalSinceNow) >= kSignedPreKeyRotationTime; = !signedPreKey || fabs(signedPreKey.generatedAt.timeIntervalSinceNow) >= kSignedPreKeyRotationTime;
if (!shouldCheck) { if (!shouldCheck) {
[rotationOperation cancel]; [weakRotationOperation cancel];
} }
}]; }];
[rotationOperation addDependency:checkIfRotationNecessaryOperation]; [rotationOperation addDependency:checkIfRotationNecessaryOperation];
// Order matters here - if we rotated *before* refreshing, we'd risk uploading // Order matters here - if we rotated *before* refreshing, we'd risk uploading

Loading…
Cancel
Save