merge IOSAD-158
authorDirk Zimmermann <dz@pep.security>
Fri, 29 Nov 2019 14:42:14 +0100
changeset 136647fecdfa178f
parent 1360 adbedc09b0fe
parent 1365 c6096d7a7673
child 1367 1d37fed6c0bd
child 1378 bfe8a5677105
merge IOSAD-158
     1.1 --- a/pEpObjCAdapter/PEPSync.m	Wed Nov 20 19:00:40 2019 +0100
     1.2 +++ b/pEpObjCAdapter/PEPSync.m	Fri Nov 29 14:42:14 2019 +0100
     1.3 @@ -160,17 +160,23 @@
     1.4  
     1.5  - (void)startup
     1.6  {
     1.7 +    if (self.syncThread != nil) {
     1.8 +        // already started
     1.9 +        return;
    1.10 +    }
    1.11 +
    1.12 +    NSThread *theSyncThread = [[NSThread alloc] initWithTarget:self
    1.13 +                                                      selector:@selector(syncThreadLoop:)
    1.14 +                                                        object:nil];
    1.15 +    theSyncThread.name = @"pEp-sync-loop";
    1.16 +    self.syncThread = theSyncThread;
    1.17 +
    1.18      // Make sure queue is empty when we start.
    1.19      [self.queue removeAllObjects];
    1.20  
    1.21      [self assureMainSessionExists];
    1.22  
    1.23      self.conditionLockForJoiningSyncThread = [[NSConditionLock alloc] initWithCondition:NO];
    1.24 -    NSThread *theSyncThread = [[NSThread alloc] initWithTarget:self
    1.25 -                                                      selector:@selector(syncThreadLoop:)
    1.26 -                                                        object:nil];
    1.27 -    theSyncThread.name = @"pEp-sync-loop";
    1.28 -    self.syncThread = theSyncThread;
    1.29      [theSyncThread start];
    1.30  }
    1.31  
    1.32 @@ -228,6 +234,7 @@
    1.33  
    1.34      session = nil;
    1.35  
    1.36 +    self.syncThread = nil;
    1.37      [self.conditionLockForJoiningSyncThread unlockWithCondition:YES];
    1.38  }
    1.39