Removed _Atomic. krista-temp
authorKrista Bennett <krista@pep-project.org>
Sun, 01 Oct 2017 18:06:09 +0200
branchkrista-temp
changeset 2125a61a551828ed
parent 2124 fea99fd1cd4f
child 2126 fdefbd3b66de
Removed _Atomic.
src/pEpEngine.c
     1.1 --- a/src/pEpEngine.c	Sun Oct 01 18:00:58 2017 +0200
     1.2 +++ b/src/pEpEngine.c	Sun Oct 01 18:06:09 2017 +0200
     1.3 @@ -8,8 +8,7 @@
     1.4  #include "blacklist.h"
     1.5  #include "sync_fsm.h"
     1.6  
     1.7 -// This is C 2011
     1.8 -static _Atomic volatile int init_count = -1;
     1.9 +static volatile int init_count = -1;
    1.10  
    1.11  // sql overloaded functions - modified from sqlite3.c
    1.12  static void _sql_lower(sqlite3_context* ctx, int argc, sqlite3_value** argv) {
    1.13 @@ -265,8 +264,8 @@
    1.14      // a little race condition - but still a race condition
    1.15      // mitigated by calling caveat (see documentation)
    1.16  
    1.17 -    // This increment is made atomic by using "_Atomic volatile" qualifier thus
    1.18 -    // ensuring consistent counting provided that init/release calls are balanced
    1.19 +    // this increment is made atomic IN THE ADAPTERS by
    1.20 +    // guarding the call to init with the appropriate mutex.
    1.21      int _count = ++init_count;
    1.22      if (_count == 0)
    1.23          in_first = true;
    1.24 @@ -274,7 +273,11 @@
    1.25      // Race contition mitigated by calling caveat starts here :
    1.26      // If another call to init() preempts right now, then preemptive call
    1.27      // will have in_first false, will not create SQL tables, and following
    1.28 -    // calls relying on those tables will fail. Therefore, first session
    1.29 +    // calls relying on those tables will fail.
    1.30 +    //
    1.31 +    // Therefore, as above, adapters MUST guard init() with a mutex.
    1.32 +    // 
    1.33 +    // Therefore, first session
    1.34      // is to be created and last session to be deleted alone, and not
    1.35      // concurently to other sessions creation or deletion.
    1.36      // We expect adapters to enforce this either by implicitely creating a
    1.37 @@ -795,7 +798,7 @@
    1.38  
    1.39      // a small race condition but still a race condition
    1.40      // mitigated by calling caveat (see documentation)
    1.41 -
    1.42 +    // (release() is to be guarded by a mutex by the caller)
    1.43      if (_count == -1)
    1.44          out_last = true;
    1.45