IOSAD-47 PEPObjCAdapter+Internal.h has an initLock and uses it
authorDirk Zimmermann <dirk@pep-project.org>
Wed, 04 Oct 2017 17:29:00 +0200
changeset 25455a28fe1d9f9
parent 253 8b302fa1d5c6
child 255 e8749386fdf0
IOSAD-47 PEPObjCAdapter+Internal.h has an initLock and uses it
pEpObjCAdapter/PEPObjCAdapter+Internal.h
pEpObjCAdapter/PEPObjCAdapter.h
pEpObjCAdapter/PEPObjCAdapter.m
pEpObjCAdapter/PEPSession.m
     1.1 --- a/pEpObjCAdapter/PEPObjCAdapter+Internal.h	Wed Oct 04 16:26:21 2017 +0200
     1.2 +++ b/pEpObjCAdapter/PEPObjCAdapter+Internal.h	Wed Oct 04 17:29:00 2017 +0200
     1.3 @@ -17,6 +17,11 @@
     1.4  
     1.5  @interface PEPObjCAdapter ()
     1.6  
     1.7 +/**
     1.8 + The lock that should be used for locking all session init() and release().
     1.9 + */
    1.10 ++ (NSLock *)initLock;
    1.11 +
    1.12  // this messages are for internal use only; do not call
    1.13  
    1.14  + (void)registerExamineFunction:(PEP_SESSION)session;
     2.1 --- a/pEpObjCAdapter/PEPObjCAdapter.h	Wed Oct 04 16:26:21 2017 +0200
     2.2 +++ b/pEpObjCAdapter/PEPObjCAdapter.h	Wed Oct 04 17:29:00 2017 +0200
     2.3 @@ -6,8 +6,6 @@
     2.4  //  Copyright (c) 2015 p≡p. All rights reserved.
     2.5  //
     2.6  
     2.7 -extern NSLock initLock;
     2.8 -
     2.9  #import <Foundation/Foundation.h>
    2.10  
    2.11  #include "message_api.h"
     3.1 --- a/pEpObjCAdapter/PEPObjCAdapter.m	Wed Oct 04 16:26:21 2017 +0200
     3.2 +++ b/pEpObjCAdapter/PEPObjCAdapter.m	Wed Oct 04 17:29:00 2017 +0200
     3.3 @@ -104,13 +104,19 @@
     3.4  
     3.5  const char* _Nullable SystemDB = NULL;
     3.6  NSURL *s_homeURL;
     3.7 -NSLock initLock = [[NSLock alloc] init];
     3.8 +static NSLock *s_initLock;
     3.9  
    3.10  @implementation PEPObjCAdapter
    3.11  
    3.12  + (void)initialize
    3.13  {
    3.14      s_homeURL = [self createApplicationDirectory];
    3.15 +    s_initLock = [[NSLock alloc] init];
    3.16 +}
    3.17 +
    3.18 ++ (NSLock *)initLock
    3.19 +{
    3.20 +    return s_initLock;
    3.21  }
    3.22  
    3.23  + (NSURL *)homeURL
    3.24 @@ -340,9 +346,9 @@
    3.25          
    3.26          syncThreadJoinCond = [[NSConditionLock alloc] initWithCondition:NO];
    3.27  
    3.28 -        [initLock lock];
    3.29 +        [[PEPObjCAdapter initLock] lock];
    3.30          PEP_STATUS status = init(&sync_session);
    3.31 -        [initLock unlock];
    3.32 +        [[PEPObjCAdapter initLock] unlock];
    3.33          if (status != PEP_STATUS_OK) {
    3.34              return;
    3.35          }
    3.36 @@ -398,9 +404,9 @@
    3.37          [syncThreadJoinCond lockWhenCondition:YES];
    3.38          [syncThreadJoinCond unlock];
    3.39  
    3.40 -        [initLock lock];
    3.41 +        [[PEPObjCAdapter initLock] lock];
    3.42          release(sync_session);
    3.43 -        [initLock unlock];
    3.44 +        [[PEPObjCAdapter initLock] unlock];
    3.45          
    3.46          sync_session = NULL;
    3.47          syncThread = nil;
     4.1 --- a/pEpObjCAdapter/PEPSession.m	Wed Oct 04 16:26:21 2017 +0200
     4.2 +++ b/pEpObjCAdapter/PEPSession.m	Wed Oct 04 17:29:00 2017 +0200
     4.3 @@ -30,9 +30,9 @@
     4.4  {
     4.5      [PEPSession setupTrustWordsDB];
     4.6  
     4.7 -    [initLock lock];    
     4.8 +    [[PEPObjCAdapter initLock] lock];
     4.9      PEP_STATUS status = init(&_session);
    4.10 -    [initLock unlock];
    4.11 +    [[PEPObjCAdapter initLock] unlock];
    4.12  
    4.13      if (status != PEP_STATUS_OK) {
    4.14          return nil;
    4.15 @@ -47,9 +47,9 @@
    4.16  {
    4.17      [PEPObjCAdapter unbindSession:self];
    4.18  
    4.19 -    [initLock lock];
    4.20 +    [[PEPObjCAdapter initLock] lock];
    4.21      release(_session);
    4.22 -    [initLock unlock];
    4.23 +    [[PEPObjCAdapter initLock] unlock];
    4.24  
    4.25  }
    4.26