IOSAD-157 Differentiate between app/engine shutdown IOSAD-157
authorDirk Zimmermann <dz@pep.security>
Wed, 20 Nov 2019 16:39:59 +0100
branchIOSAD-157
changeset 13579295e6eceea7
parent 1356 26652ce6f2d8
child 1358 8266b8194627
IOSAD-157 Differentiate between app/engine shutdown
pEpObjCAdapter/PEPSync.m
     1.1 --- a/pEpObjCAdapter/PEPSync.m	Wed Nov 20 16:39:59 2019 +0100
     1.2 +++ b/pEpObjCAdapter/PEPSync.m	Wed Nov 20 16:39:59 2019 +0100
     1.3 @@ -50,7 +50,7 @@
     1.4  
     1.5  - (PEP_STATUS)messageToSend:(struct _message *)msg;
     1.6  
     1.7 -- (int)injectSyncEvent:(SYNC_EVENT)event;
     1.8 +- (int)injectSyncEvent:(SYNC_EVENT)event isFromShutdown:(BOOL)isFromShutdown;
     1.9  
    1.10  - (PEP_STATUS)notifyHandshake:(pEp_identity *)me
    1.11                        partner:(pEp_identity *)partner
    1.12 @@ -78,7 +78,9 @@
    1.13      PEPSync *pEpSync = [PEPSync instance];
    1.14  
    1.15      if (pEpSync) {
    1.16 -        return [pEpSync injectSyncEvent:ev];
    1.17 +        // The inject comes from the engine, so we know it's not the
    1.18 +        // adapter client calling shutdown.
    1.19 +        return [pEpSync injectSyncEvent:ev isFromShutdown:NO];
    1.20      } else {
    1.21          return 1;
    1.22      }
    1.23 @@ -175,7 +177,7 @@
    1.24  - (void)shutdown
    1.25  {
    1.26      if (self.syncThread) {
    1.27 -        [self injectSyncEvent:nil];
    1.28 +        [self injectSyncEvent:nil isFromShutdown:YES];
    1.29      }
    1.30  }
    1.31  
    1.32 @@ -239,7 +241,7 @@
    1.33      }
    1.34  }
    1.35  
    1.36 -- (int)injectSyncEvent:(SYNC_EVENT)event
    1.37 +- (int)injectSyncEvent:(SYNC_EVENT)event isFromShutdown:(BOOL)isFromShutdown
    1.38  {
    1.39      NSValue *value = [NSValue valueWithBytes:&event objCType:@encode(SYNC_EVENT)];
    1.40  
    1.41 @@ -250,7 +252,10 @@
    1.42          [self.conditionLockForJoiningSyncThread lockWhenCondition:YES];
    1.43          [self.conditionLockForJoiningSyncThread unlock];
    1.44          self.conditionLockForJoiningSyncThread = nil;
    1.45 -        [self.notifyHandshakeDelegate keySyncDisabled];
    1.46 +        if (!isFromShutdown) {
    1.47 +            // Only inform the delegate if the shutdown came from the engine
    1.48 +            [self.notifyHandshakeDelegate keySyncDisabled];
    1.49 +        }
    1.50      }
    1.51  
    1.52      return 0;