IOSAD-124 rm remainig- and already commetned locks IOSAD-124
authorbuff <andreas@pep-project.org>
Sun, 21 Jul 2019 18:28:56 +0200
branchIOSAD-124
changeset 107381b106a91ee2
parent 1072 a5b4592a4748
child 1074 19e3a4f59580
IOSAD-124 rm remainig- and already commetned locks
pEpObjCAdapter/PEPInternalSession.m
pEpObjCAdapter/PEPObjCAdapter.m
pEpObjCAdapter/PEPSync.m
     1.1 --- a/pEpObjCAdapter/PEPInternalSession.m	Sun Jul 21 18:27:58 2019 +0200
     1.2 +++ b/pEpObjCAdapter/PEPInternalSession.m	Sun Jul 21 18:28:56 2019 +0200
     1.3 @@ -24,7 +24,6 @@
     1.4  #import "PEPAutoPointer.h"
     1.5  #import "NSNumber+PEPRating.h"
     1.6  #import "NSMutableDictionary+PEP.h"
     1.7 -#import "PEPLock.h"
     1.8  #import "PEPSync_Internal.h"
     1.9  
    1.10  #import "key_reset.h"
    1.11 @@ -49,7 +48,7 @@
    1.12  
    1.13  - (void)dealloc
    1.14  {
    1.15 -    [PEPSync releaseSession:_session];
    1.16 +    release(_session);
    1.17  }
    1.18  
    1.19  #pragma mark - CONFIG
    1.20 @@ -61,16 +60,6 @@
    1.21  
    1.22  #pragma mark - INTERNAL
    1.23  
    1.24 -- (void)lockWrite
    1.25 -{
    1.26 -    [PEPLock lockWrite];
    1.27 -}
    1.28 -
    1.29 -- (void)unlockWrite
    1.30 -{
    1.31 -    [PEPLock unlockWrite];
    1.32 -}
    1.33 -
    1.34  + (void)setupTrustWordsDB
    1.35  {
    1.36      static dispatch_once_t once;
    1.37 @@ -133,14 +122,12 @@
    1.38  
    1.39      PEPRating internalRating = PEPRatingUndefined;
    1.40  
    1.41 -    //[self lockWrite];
    1.42      PEPStatus theStatus = (PEPStatus) decrypt_message(_session,
    1.43                                                        _src,
    1.44                                                        &_dst,
    1.45                                                        &theKeys,
    1.46                                                        (PEP_rating *) &internalRating,
    1.47                                                        (PEP_decrypt_flags *) &theFlags);
    1.48 -    //[self unlockWrite];
    1.49  
    1.50      if (status) {
    1.51          *status = theStatus;
    1.52 @@ -217,13 +204,11 @@
    1.53          theKeys = PEP_arrayToStringlist(xKeyList);
    1.54      }
    1.55  
    1.56 -    //[self lockWrite];
    1.57      PEPStatus theStatus = (PEPStatus) re_evaluate_message_rating(_session,
    1.58                                                                   _src,
    1.59                                                                   theKeys,
    1.60                                                                   (PEP_rating) *rating,
    1.61                                                                   (PEP_rating *) rating);
    1.62 -    //[self unlockWrite];
    1.63  
    1.64      free_message(_src);
    1.65      free_stringlist(theKeys);
    1.66 @@ -361,7 +346,6 @@
    1.67  
    1.68      stringlist_t *keysStringList = PEP_arrayToStringlist(extraKeys);
    1.69  
    1.70 -    //[self lockWrite];
    1.71      PEPStatus theStatus = (PEPStatus) encrypt_message_for_self(_session,
    1.72                                                                 ident,
    1.73                                                                 _src,
    1.74 @@ -369,7 +353,6 @@
    1.75                                                                 &_dst,
    1.76                                                                 PEP_enc_PGP_MIME,
    1.77                                                                 flags);
    1.78 -    //[self unlockWrite];
    1.79  
    1.80      free_stringlist(keysStringList);
    1.81  
    1.82 @@ -430,12 +413,10 @@
    1.83      message *src = PEP_messageDictToStruct([self removeEmptyRecipients:messageDict]);
    1.84      message *dst = NULL;
    1.85  
    1.86 -    //[self lockWrite];
    1.87      PEPStatus theStatus = (PEPStatus)
    1.88      encrypt_message_and_add_priv_key(_session, src, &dst,
    1.89                                       [[toFpr precomposedStringWithCanonicalMapping] UTF8String],
    1.90                                       (PEP_enc_format) encFormat, flags);
    1.91 -    //[self unlockWrite];
    1.92  
    1.93      if (status) {
    1.94          *status = theStatus;
    1.95 @@ -485,11 +466,9 @@
    1.96      message *_msg = PEP_messageToStruct(theMessage);
    1.97      PEPRating rating = PEPRatingUndefined;
    1.98  
    1.99 -    //[self lockWrite];
   1.100      PEPStatus status = (PEPStatus) outgoing_message_rating(_session,
   1.101                                                             _msg,
   1.102                                                             (PEP_rating *) &rating);
   1.103 -    //[self unlockWrite];
   1.104  
   1.105      free_message(_msg);
   1.106  
   1.107 @@ -524,9 +503,7 @@
   1.108      pEp_identity *ident = PEP_identityToStruct(identity);
   1.109      PEPRating rating = PEPRatingUndefined;
   1.110  
   1.111 -    //[self lockWrite];
   1.112      PEPStatus status = (PEPStatus) identity_rating(_session, ident, (PEP_rating *) &rating);
   1.113 -    //[self unlockWrite];
   1.114  
   1.115      free_identity(ident);
   1.116  
   1.117 @@ -577,9 +554,7 @@
   1.118  {
   1.119      pEp_identity *ident = PEP_identityToStruct(identity);
   1.120  
   1.121 -    //[self lockWrite];
   1.122      PEPStatus status = (PEPStatus) myself(_session, ident);
   1.123 -    //[self unlockWrite];
   1.124  
   1.125      if ([NSError setError:error fromPEPStatus:status]) {
   1.126          free_identity(ident);
   1.127 @@ -600,10 +575,8 @@
   1.128      } else {
   1.129          pEp_identity *ident = PEP_identityToStruct(identity);
   1.130  
   1.131 -        //[self lockWrite];
   1.132          PEPStatus status = (PEPStatus) update_identity(_session, ident);
   1.133 -        //[self unlockWrite];
   1.134 -
   1.135 +        
   1.136          if ([NSError setError:error fromPEPStatus:status]) {
   1.137              free_identity(ident);
   1.138              return NO;
   1.139 @@ -622,9 +595,7 @@
   1.140  {
   1.141      pEp_identity *ident = PEP_identityToStruct(identity);
   1.142  
   1.143 -    //[self lockWrite];
   1.144      PEPStatus status = (PEPStatus) trust_personal_key(_session, ident);
   1.145 -    //[self unlockWrite];
   1.146  
   1.147      if ([NSError setError:error fromPEPStatus:status]) {
   1.148          free_identity(ident);
   1.149 @@ -641,9 +612,7 @@
   1.150  {
   1.151      pEp_identity *ident = PEP_identityToStruct(identity);
   1.152  
   1.153 -    //[self lockWrite];
   1.154      PEPStatus status = (PEPStatus) key_mistrusted(_session, ident);
   1.155 -    //[self unlockWrite];
   1.156  
   1.157      if ([NSError setError:error fromPEPStatus:status]) {
   1.158          free_identity(ident);
   1.159 @@ -662,9 +631,7 @@
   1.160  {
   1.161      pEp_identity *ident = PEP_identityToStruct(identity);
   1.162  
   1.163 -    //[self lockWrite];
   1.164      PEPStatus status = (PEPStatus) key_reset_trust(_session, ident);
   1.165 -    //[self unlockWrite];
   1.166  
   1.167      if ([NSError setError:error fromPEPStatus:status]) {
   1.168          free_identity(ident);
   1.169 @@ -683,11 +650,9 @@
   1.170  {
   1.171      identity_list *identList = NULL;
   1.172  
   1.173 -    //[self lockWrite];
   1.174      PEPStatus status = (PEPStatus) import_key(_session,
   1.175 -                                   [[keydata precomposedStringWithCanonicalMapping] UTF8String],
   1.176 -                                   [keydata length], &identList);
   1.177 -    //[self unlockWrite];
   1.178 +                                              [[keydata precomposedStringWithCanonicalMapping] UTF8String],
   1.179 +                                              [keydata length], &identList);
   1.180  
   1.181      if ([NSError setError:error fromPEPStatus:status]) {
   1.182          free(identList);
   1.183 @@ -706,7 +671,6 @@
   1.184           comment:(NSString * _Nullable)comment
   1.185             error:(NSError * _Nullable * _Nullable)error
   1.186  {
   1.187 -    //[self lockWrite];
   1.188      PEPStatus status = (PEPStatus) log_event(_session,
   1.189                                               [[title precomposedStringWithCanonicalMapping]
   1.190                                                UTF8String],
   1.191 @@ -716,7 +680,6 @@
   1.192                                                UTF8String],
   1.193                                               [[comment precomposedStringWithCanonicalMapping]
   1.194                                                UTF8String]);
   1.195 -    //[self unlockWrite];
   1.196  
   1.197      if ([NSError setError:error fromPEPStatus:status]) {
   1.198          return NO;
   1.199 @@ -755,12 +718,10 @@
   1.200      PEPAutoPointer *trustwords = [PEPAutoPointer new];
   1.201      size_t sizeWritten = 0;
   1.202  
   1.203 -    //[self lockWrite];
   1.204      status = (PEPStatus) get_trustwords(_session, ident1, ident2,
   1.205                                          [[language precomposedStringWithCanonicalMapping]
   1.206                                           UTF8String],
   1.207                                          trustwords.charPointerPointer, &sizeWritten, full);
   1.208 -    //[self unlockWrite];
   1.209  
   1.210      free_identity(ident1);
   1.211      free_identity(ident2);
   1.212 @@ -787,13 +748,11 @@
   1.213      
   1.214      PEPAutoPointer *trustwords = [PEPAutoPointer new];
   1.215      size_t sizeWritten = 0;
   1.216 -    
   1.217 -    //[self lockWrite];
   1.218 +
   1.219      status = (PEPStatus) get_trustwords_for_fprs(_session, _fpr1, _fpr2,
   1.220                                          [[language precomposedStringWithCanonicalMapping]
   1.221                                           UTF8String],
   1.222 -                                        trustwords.charPointerPointer, &sizeWritten, full);
   1.223 -    //[self unlockWrite];
   1.224 +                                                 trustwords.charPointerPointer, &sizeWritten, full);
   1.225      
   1.226      NSString *result = nil;
   1.227      
     2.1 --- a/pEpObjCAdapter/PEPObjCAdapter.m	Sun Jul 21 18:27:58 2019 +0200
     2.2 +++ b/pEpObjCAdapter/PEPObjCAdapter.m	Sun Jul 21 18:28:56 2019 +0200
     2.3 @@ -12,7 +12,6 @@
     2.4  #import "PEPObjCAdapter+Internal.h"
     2.5  #import "PEPMessageUtil.h"
     2.6  #import "NSError+PEP.h"
     2.7 -#import "PEPLock.h"
     2.8  
     2.9  #import "keymanagement.h"
    2.10  #import "mime.h"
     3.1 --- a/pEpObjCAdapter/PEPSync.m	Sun Jul 21 18:27:58 2019 +0200
     3.2 +++ b/pEpObjCAdapter/PEPSync.m	Sun Jul 21 18:28:56 2019 +0200
     3.3 @@ -17,7 +17,6 @@
     3.4  #import "PEPMessageUtil.h"
     3.5  #import "PEPMessage.h"
     3.6  #import "PEPQueue.h"
     3.7 -#import "PEPLock.h"
     3.8  #import "PEPObjCAdapter.h"
     3.9  #import "NSError+PEP+Internal.h"
    3.10  #import "PEPSessionProvider.h"
    3.11 @@ -126,11 +125,9 @@
    3.12  {
    3.13      PEP_SESSION session = NULL;
    3.14  
    3.15 -    [PEPLock lockWrite];
    3.16      PEP_STATUS status = init(&session,
    3.17                               [PEPSync messageToSendCallback],
    3.18                               [PEPSync injectSyncCallback]);
    3.19 -    [PEPLock unlockWrite];
    3.20  
    3.21      if (status != PEP_STATUS_OK) {
    3.22          if (error) {
    3.23 @@ -142,13 +139,6 @@
    3.24      return session;
    3.25  }
    3.26  
    3.27 -+ (void)releaseSession:(PEP_SESSION)session
    3.28 -{
    3.29 -    [PEPLock lockWrite];
    3.30 -    release(session);
    3.31 -    [PEPLock unlockWrite];
    3.32 -}
    3.33 -
    3.34  - (instancetype)initWithSendMessageDelegate:(id<PEPSendMessageDelegate>
    3.35                                               _Nullable)sendMessageDelegate
    3.36                      notifyHandshakeDelegate:(id<PEPNotifyHandshakeDelegate>