IOSAD-172 We are already running on our queue IOSAD-172
authorDirk Zimmermann <dz@pep.security>
Fri, 26 Jun 2020 16:54:34 +0200
branchIOSAD-172
changeset 14775cb57fd85d00
parent 1476 388741294076
child 1478 17e48ad64829
IOSAD-172 We are already running on our queue
pEpObjCAdapter/PEPPassphraseCache.m
     1.1 --- a/pEpObjCAdapter/PEPPassphraseCache.m	Fri Jun 26 16:54:34 2020 +0200
     1.2 +++ b/pEpObjCAdapter/PEPPassphraseCache.m	Fri Jun 26 16:54:34 2020 +0200
     1.3 @@ -85,24 +85,23 @@
     1.4  }
     1.5  
     1.6  /// Remove password entries that have timed out.
     1.7 +/// - Note: Assumes it gets called on `queue`.
     1.8  - (void)removeStaleEntries
     1.9  {
    1.10      NSDate *now = [NSDate date];
    1.11      NSDate *minimum = [now dateByAddingTimeInterval:-s_defaultTimeoutInSeconds];
    1.12      NSTimeInterval minimumTimeInterval = [minimum timeIntervalSinceReferenceDate];
    1.13 -    dispatch_sync(self.queue, ^{
    1.14 -        NSMutableArray *resultingPassphrases = [NSMutableArray
    1.15 -                                                arrayWithCapacity:s_maxNumberOfPassphrases];
    1.16 +    NSMutableArray *resultingPassphrases = [NSMutableArray
    1.17 +                                            arrayWithCapacity:s_maxNumberOfPassphrases];
    1.18  
    1.19 -        for (PEPPassphraseCacheEntry *entry in self.mutablePassphrases) {
    1.20 -            if ([entry.dateAdded timeIntervalSinceReferenceDate] >= minimumTimeInterval) {
    1.21 -                [resultingPassphrases addObject:entry];
    1.22 -            }
    1.23 +    for (PEPPassphraseCacheEntry *entry in self.mutablePassphrases) {
    1.24 +        if ([entry.dateAdded timeIntervalSinceReferenceDate] >= minimumTimeInterval) {
    1.25 +            [resultingPassphrases addObject:entry];
    1.26          }
    1.27 +    }
    1.28  
    1.29 -        [self.mutablePassphrases removeAllObjects];
    1.30 -        [self.mutablePassphrases addObjectsFromArray:resultingPassphrases];
    1.31 -    });
    1.32 +    [self.mutablePassphrases removeAllObjects];
    1.33 +    [self.mutablePassphrases addObjectsFromArray:resultingPassphrases];
    1.34  }
    1.35  
    1.36  @end