IOSAD-158 Ignore PEPSync.start when already running IOSAD-158
authorDirk Zimmermann <dz@pep.security>
Fri, 29 Nov 2019 12:26:37 +0100
branchIOSAD-158
changeset 1362ab1fd1f9125d
parent 1361 d4fbe8a9eb31
child 1363 777e67b15f52
IOSAD-158 Ignore PEPSync.start when already running
pEpObjCAdapter/PEPSync.m
     1.1 --- a/pEpObjCAdapter/PEPSync.m	Fri Nov 29 11:22:52 2019 +0100
     1.2 +++ b/pEpObjCAdapter/PEPSync.m	Fri Nov 29 12:26:37 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