spinlock implementation for dealing with write locks sync
authorVolker Birk <vb@pep-project.org>
Tue, 21 May 2019 07:04:51 +0200
branchsync
changeset 3739523fb9710660
parent 3737 80bf2f5a285d
child 3740 248166aa4ab2
child 3741 6f92319aefbb
child 3743 a66f640552a4
child 3749 aa25e3e32641
child 3751 c40e8cffdb1d
spinlock implementation for dealing with write locks
src/blacklist.c
src/key_reset.c
src/keymanagement.c
src/pEpEngine.c
src/pEp_internal.h
src/pgp_sequoia.c
sync/sql_func.yml2
     1.1 --- a/src/blacklist.c	Mon May 20 14:49:40 2019 +0200
     1.2 +++ b/src/blacklist.c	Tue May 21 07:04:51 2019 +0200
     1.3 @@ -20,7 +20,7 @@
     1.4  
     1.5      int result;
     1.6  
     1.7 -    result = sqlite3_step(session->blacklist_add);
     1.8 +    result = Sqlite3_step(session->blacklist_add);
     1.9      switch (result) {
    1.10      case SQLITE_DONE:
    1.11          status = PEP_STATUS_OK;
    1.12 @@ -50,7 +50,7 @@
    1.13  
    1.14      int result;
    1.15  
    1.16 -    result = sqlite3_step(session->blacklist_delete);
    1.17 +    result = Sqlite3_step(session->blacklist_delete);
    1.18      switch (result) {
    1.19      case SQLITE_DONE:
    1.20          status = PEP_STATUS_OK;
    1.21 @@ -85,7 +85,7 @@
    1.22  
    1.23      int result;
    1.24  
    1.25 -    result = sqlite3_step(session->blacklist_is_listed);
    1.26 +    result = Sqlite3_step(session->blacklist_is_listed);
    1.27      switch (result) {
    1.28      case SQLITE_ROW:
    1.29          count = sqlite3_column_int(session->blacklist_is_listed, 0);
    1.30 @@ -125,7 +125,7 @@
    1.31  
    1.32      stringlist_t *_bl = _blacklist;
    1.33      do {
    1.34 -        result = sqlite3_step(session->blacklist_retrieve);
    1.35 +        result = Sqlite3_step(session->blacklist_retrieve);
    1.36          switch (result) {
    1.37          case SQLITE_ROW:
    1.38          {
     2.1 --- a/src/key_reset.c	Mon May 20 14:49:40 2019 +0200
     2.2 +++ b/src/key_reset.c	Tue May 21 07:04:51 2019 +0200
     2.3 @@ -39,7 +39,7 @@
     2.4              SQLITE_STATIC);
     2.5      sqlite3_bind_text(session->was_id_for_revoke_contacted, 2, user_id, -1,
     2.6              SQLITE_STATIC);        
     2.7 -    int result = sqlite3_step(session->was_id_for_revoke_contacted);
     2.8 +    int result = Sqlite3_step(session->was_id_for_revoke_contacted);
     2.9      switch (result) {
    2.10          case SQLITE_ROW: {
    2.11              *contacted = (sqlite3_column_int(session->was_id_for_revoke_contacted, 0) != 0);
    2.12 @@ -79,7 +79,7 @@
    2.13  
    2.14      int result;
    2.15      
    2.16 -    result = sqlite3_step(session->set_revoke_contact_as_notified);
    2.17 +    result = Sqlite3_step(session->set_revoke_contact_as_notified);
    2.18      switch (result) {
    2.19          case SQLITE_DONE:
    2.20              status = PEP_STATUS_OK;
     3.1 --- a/src/keymanagement.c	Mon May 20 14:49:40 2019 +0200
     3.2 +++ b/src/keymanagement.c	Tue May 21 07:04:51 2019 +0200
     3.3 @@ -282,7 +282,7 @@
     3.4  
     3.5      int result = -1;
     3.6      
     3.7 -    while ((result = sqlite3_step(session->get_all_keys_for_user)) == SQLITE_ROW) {
     3.8 +    while ((result = Sqlite3_step(session->get_all_keys_for_user)) == SQLITE_ROW) {
     3.9          const char* keyres = (const char *) sqlite3_column_text(session->get_all_keys_for_user, 0);
    3.10          if (keyres) {
    3.11              if (_kl)
    3.12 @@ -317,7 +317,7 @@
    3.13      sqlite3_bind_text(session->get_user_default_key, 1, user_id, 
    3.14                        -1, SQLITE_STATIC);
    3.15      
    3.16 -    const int result = sqlite3_step(session->get_user_default_key);
    3.17 +    const int result = Sqlite3_step(session->get_user_default_key);
    3.18      char* user_fpr = NULL;
    3.19      if (result == SQLITE_ROW) {
    3.20          const char* u_fpr =
    3.21 @@ -1621,7 +1621,7 @@
    3.22      
    3.23      int result;
    3.24      
    3.25 -    result = sqlite3_step(session->own_key_is_listed);
    3.26 +    result = Sqlite3_step(session->own_key_is_listed);
    3.27      switch (result) {
    3.28          case SQLITE_ROW:
    3.29              count = sqlite3_column_int(session->own_key_is_listed, 0);
    3.30 @@ -1671,7 +1671,7 @@
    3.31      sqlite3_bind_int(session->own_identities_retrieve, 1, excluded_flags);
    3.32  
    3.33      do {
    3.34 -        result = sqlite3_step(session->own_identities_retrieve);
    3.35 +        result = Sqlite3_step(session->own_identities_retrieve);
    3.36          switch (result) {
    3.37              case SQLITE_ROW:
    3.38                  address = (const char *)
    3.39 @@ -1765,7 +1765,7 @@
    3.40      sqlite3_bind_int(session->own_keys_retrieve, 1, excluded_flags);
    3.41  
    3.42      do {        
    3.43 -        result = sqlite3_step(session->own_keys_retrieve);
    3.44 +        result = Sqlite3_step(session->own_keys_retrieve);
    3.45          switch (result) {
    3.46              case SQLITE_ROW:
    3.47                  _bl = stringlist_add(_bl, (const char *)
    3.48 @@ -1906,7 +1906,7 @@
    3.49      sqlite3_bind_text(session->add_mistrusted_key, 1, fpr, -1,
    3.50              SQLITE_STATIC);
    3.51  
    3.52 -    result = sqlite3_step(session->add_mistrusted_key);
    3.53 +    result = Sqlite3_step(session->add_mistrusted_key);
    3.54      sqlite3_reset(session->add_mistrusted_key);
    3.55  
    3.56      if (result != SQLITE_DONE)
    3.57 @@ -1928,7 +1928,7 @@
    3.58      sqlite3_bind_text(session->delete_mistrusted_key, 1, fpr, -1,
    3.59              SQLITE_STATIC);
    3.60  
    3.61 -    result = sqlite3_step(session->delete_mistrusted_key);
    3.62 +    result = Sqlite3_step(session->delete_mistrusted_key);
    3.63      sqlite3_reset(session->delete_mistrusted_key);
    3.64  
    3.65      if (result != SQLITE_DONE)
    3.66 @@ -1955,7 +1955,7 @@
    3.67  
    3.68      int result;
    3.69  
    3.70 -    result = sqlite3_step(session->is_mistrusted_key);
    3.71 +    result = Sqlite3_step(session->is_mistrusted_key);
    3.72      switch (result) {
    3.73      case SQLITE_ROW:
    3.74          *mistrusted = sqlite3_column_int(session->is_mistrusted_key, 0);
     4.1 --- a/src/pEpEngine.c	Mon May 20 14:49:40 2019 +0200
     4.2 +++ b/src/pEpEngine.c	Tue May 21 07:04:51 2019 +0200
     4.3 @@ -533,7 +533,7 @@
     4.4  
     4.5      int retval = 0;
     4.6  
     4.7 -    int rc = sqlite3_step(stmt);  
     4.8 +    int rc = Sqlite3_step(stmt);  
     4.9      if (rc == SQLITE_DONE || rc == SQLITE_OK || rc == SQLITE_ROW) {
    4.10          retval = 1;
    4.11      }
    4.12 @@ -584,7 +584,7 @@
    4.13  
    4.14      int retval = 0;
    4.15  
    4.16 -    int rc = sqlite3_step(stmt);  
    4.17 +    int rc = Sqlite3_step(stmt);  
    4.18      if (rc == SQLITE_DONE || rc == SQLITE_OK || rc == SQLITE_ROW) {
    4.19          retval = 1;
    4.20      }
    4.21 @@ -607,7 +607,7 @@
    4.22      sqlite3_prepare_v2(session->db, sql_query, -1, &stmt, NULL);
    4.23      int i = 0;
    4.24      int int_result = 0;
    4.25 -    while ((int_result = sqlite3_step(stmt)) == SQLITE_ROW && i < _PEP_MAX_AFFECTED) {
    4.26 +    while ((int_result = Sqlite3_step(stmt)) == SQLITE_ROW && i < _PEP_MAX_AFFECTED) {
    4.27          table_names[i++] = strdup((const char*)(sqlite3_column_text(stmt, 0)));
    4.28      }
    4.29      
    4.30 @@ -2040,7 +2040,7 @@
    4.31      //     sqlite3_bind_text(session->log, 4, comment, -1, SQLITE_STATIC);
    4.32      // else
    4.33      //     sqlite3_bind_null(session->log, 4);
    4.34 -    // result = sqlite3_step(session->log);
    4.35 +    // result = Sqlite3_step(session->log);
    4.36      // sqlite3_reset(session->log);
    4.37      // 
    4.38      return PEP_STATUS_OK; // We ignore errors for this function.
    4.39 @@ -2094,7 +2094,7 @@
    4.40      sqlite3_bind_text(session->trustword, 1, lang, -1, SQLITE_STATIC);
    4.41      sqlite3_bind_int(session->trustword, 2, value);
    4.42  
    4.43 -    const int result = sqlite3_step(session->trustword);
    4.44 +    const int result = Sqlite3_step(session->trustword);
    4.45      if (result == SQLITE_ROW) {
    4.46          *word = strdup((const char *) sqlite3_column_text(session->trustword,
    4.47                      1));
    4.48 @@ -2289,7 +2289,7 @@
    4.49      
    4.50      sqlite3_reset(session->get_default_own_userid);
    4.51  
    4.52 -    const int result = sqlite3_step(session->get_default_own_userid);
    4.53 +    const int result = Sqlite3_step(session->get_default_own_userid);
    4.54      const char* id;
    4.55      
    4.56      switch (result) {
    4.57 @@ -2338,7 +2338,7 @@
    4.58  
    4.59      const char* tempid;
    4.60      
    4.61 -    const int result = sqlite3_step(session->get_userid_alias_default);
    4.62 +    const int result = Sqlite3_step(session->get_userid_alias_default);
    4.63      switch (result) {
    4.64      case SQLITE_ROW:
    4.65          tempid = (const char *) sqlite3_column_text(session->get_userid_alias_default, 0);
    4.66 @@ -2383,7 +2383,7 @@
    4.67      sqlite3_bind_text(session->add_userid_alias, 2, alias_id, -1,
    4.68              SQLITE_STATIC);
    4.69          
    4.70 -    result = sqlite3_step(session->add_userid_alias);
    4.71 +    result = Sqlite3_step(session->add_userid_alias);
    4.72  
    4.73      sqlite3_reset(session->add_userid_alias);
    4.74      if (result != SQLITE_DONE) {
    4.75 @@ -2420,7 +2420,7 @@
    4.76      sqlite3_bind_text(session->get_identity, 1, address, -1, SQLITE_STATIC);
    4.77      sqlite3_bind_text(session->get_identity, 2, user_id, -1, SQLITE_STATIC);
    4.78  
    4.79 -    const int result = sqlite3_step(session->get_identity);
    4.80 +    const int result = Sqlite3_step(session->get_identity);
    4.81      switch (result) {
    4.82      case SQLITE_ROW:
    4.83          _identity = new_identity(
    4.84 @@ -2483,7 +2483,7 @@
    4.85      sqlite3_bind_text(session->get_identities_by_userid, 1, user_id, -1, SQLITE_STATIC);
    4.86  
    4.87      int result = -1;
    4.88 -    while ((result = sqlite3_step(session->get_identities_by_userid)) == SQLITE_ROW) {
    4.89 +    while ((result = Sqlite3_step(session->get_identities_by_userid)) == SQLITE_ROW) {
    4.90              // "select address, fpr, username, comm_type, lang,"
    4.91              // "   identity.flags | pgp_keypair.flags,"
    4.92              // "   is_own"
    4.93 @@ -2561,7 +2561,7 @@
    4.94  
    4.95      int result = -1;
    4.96      
    4.97 -    while ((result = sqlite3_step(session->get_identities_by_main_key_id)) == SQLITE_ROW) {
    4.98 +    while ((result = Sqlite3_step(session->get_identities_by_main_key_id)) == SQLITE_ROW) {
    4.99          ident = new_identity(
   4.100                      (const char *) sqlite3_column_text(session->get_identities_by_main_key_id, 0),
   4.101                      fpr,
   4.102 @@ -2631,7 +2631,7 @@
   4.103      sqlite3_bind_text(session->get_identity_without_trust_check, 1, address, -1, SQLITE_STATIC);
   4.104      sqlite3_bind_text(session->get_identity_without_trust_check, 2, user_id, -1, SQLITE_STATIC);
   4.105  
   4.106 -    const int result = sqlite3_step(session->get_identity_without_trust_check);
   4.107 +    const int result = Sqlite3_step(session->get_identity_without_trust_check);
   4.108      switch (result) {
   4.109      case SQLITE_ROW:
   4.110          _identity = new_identity(
   4.111 @@ -2695,7 +2695,7 @@
   4.112      sqlite3_bind_text(session->get_identities_by_address, 1, address, -1, SQLITE_STATIC);
   4.113      int result;
   4.114  
   4.115 -    while ((result = sqlite3_step(session->get_identities_by_address)) == SQLITE_ROW) {
   4.116 +    while ((result = Sqlite3_step(session->get_identities_by_address)) == SQLITE_ROW) {
   4.117          //"select user_id, main_key_id, username, comm_type, lang,"
   4.118          //"   identity.flags, is_own"
   4.119          pEp_identity *ident = new_identity(
   4.120 @@ -2762,7 +2762,7 @@
   4.121      sqlite3_bind_text(session->exists_identity_entry, 2, identity->user_id, -1,
   4.122                        SQLITE_STATIC);
   4.123                    
   4.124 -    int result = sqlite3_step(session->exists_identity_entry);
   4.125 +    int result = Sqlite3_step(session->exists_identity_entry);
   4.126  
   4.127      switch (result) {
   4.128          case SQLITE_ROW: {
   4.129 @@ -2797,7 +2797,7 @@
   4.130      sqlite3_bind_text(session->exists_trust_entry, 2, identity->fpr, -1,
   4.131                        SQLITE_STATIC);
   4.132                    
   4.133 -    int result = sqlite3_step(session->exists_trust_entry);
   4.134 +    int result = Sqlite3_step(session->exists_trust_entry);
   4.135      switch (result) {
   4.136          case SQLITE_ROW: {
   4.137              // yeah yeah, I know, we could be lazy here, but it looks bad.
   4.138 @@ -2821,7 +2821,7 @@
   4.139      sqlite3_reset(session->set_pgp_keypair);
   4.140      sqlite3_bind_text(session->set_pgp_keypair, 1, fpr, -1,
   4.141              SQLITE_STATIC);
   4.142 -    result = sqlite3_step(session->set_pgp_keypair);
   4.143 +    result = Sqlite3_step(session->set_pgp_keypair);
   4.144      sqlite3_reset(session->set_pgp_keypair);
   4.145      if (result != SQLITE_DONE) {
   4.146          return PEP_CANNOT_SET_PGP_KEYPAIR;
   4.147 @@ -2854,7 +2854,7 @@
   4.148      sqlite3_bind_text(set_or_update, 2, identity->fpr, -1,
   4.149              SQLITE_STATIC);
   4.150      sqlite3_bind_int(set_or_update, 3, identity->comm_type);
   4.151 -    result = sqlite3_step(set_or_update);
   4.152 +    result = Sqlite3_step(set_or_update);
   4.153      assert(result == SQLITE_DONE);
   4.154      sqlite3_reset(set_or_update);
   4.155      if (result != SQLITE_DONE)
   4.156 @@ -2882,7 +2882,7 @@
   4.157              SQLITE_STATIC);
   4.158      sqlite3_bind_int(set_or_update, 4, identity->flags);
   4.159      sqlite3_bind_int(set_or_update, 5, identity->me);
   4.160 -    int result = sqlite3_step(set_or_update);
   4.161 +    int result = Sqlite3_step(set_or_update);
   4.162      sqlite3_reset(set_or_update);
   4.163      if (result != SQLITE_DONE)
   4.164          return PEP_CANNOT_SET_IDENTITY;
   4.165 @@ -2912,7 +2912,7 @@
   4.166          sqlite3_bind_null(set_or_update, 3);
   4.167      sqlite3_bind_text(set_or_update, 4, identity->fpr, -1,
   4.168                        SQLITE_STATIC);
   4.169 -    int result = sqlite3_step(set_or_update);
   4.170 +    int result = Sqlite3_step(set_or_update);
   4.171      sqlite3_reset(set_or_update);
   4.172      
   4.173      if (result != SQLITE_DONE)
   4.174 @@ -3028,7 +3028,7 @@
   4.175          sqlite3_reset(session->set_pgp_keypair);
   4.176          sqlite3_bind_text(session->set_pgp_keypair, 1, identity->fpr, -1,
   4.177                  SQLITE_STATIC);
   4.178 -        result = sqlite3_step(session->set_pgp_keypair);
   4.179 +        result = Sqlite3_step(session->set_pgp_keypair);
   4.180          sqlite3_reset(session->set_pgp_keypair);
   4.181          if (result != SQLITE_DONE) {
   4.182              sqlite3_exec(session->db, "ROLLBACK ;", NULL, NULL, NULL);
   4.183 @@ -3081,7 +3081,7 @@
   4.184      sqlite3_reset(session->update_trust_to_pEp);
   4.185      sqlite3_bind_text(session->update_trust_to_pEp, 1, user->user_id, -1,
   4.186              SQLITE_STATIC);
   4.187 -    int result = sqlite3_step(session->update_trust_to_pEp);
   4.188 +    int result = Sqlite3_step(session->update_trust_to_pEp);
   4.189      sqlite3_reset(session->update_trust_to_pEp);
   4.190      if (result != SQLITE_DONE)
   4.191          return PEP_CANNOT_SET_TRUST;
   4.192 @@ -3116,7 +3116,7 @@
   4.193      sqlite3_reset(session->set_as_pEp_user);
   4.194      sqlite3_bind_text(session->set_as_pEp_user, 1, user->user_id, -1,
   4.195              SQLITE_STATIC);
   4.196 -    int result = sqlite3_step(session->set_as_pEp_user);
   4.197 +    int result = Sqlite3_step(session->set_as_pEp_user);
   4.198      sqlite3_reset(session->set_as_pEp_user);
   4.199      
   4.200      if (result != SQLITE_DONE)
   4.201 @@ -3151,7 +3151,7 @@
   4.202          sqlite3_reset(session->exists_person);
   4.203          sqlite3_bind_text(session->exists_person, 1, user_id, -1,
   4.204                  SQLITE_STATIC);
   4.205 -        int result = sqlite3_step(session->exists_person);
   4.206 +        int result = Sqlite3_step(session->exists_person);
   4.207          switch (result) {
   4.208              case SQLITE_ROW: {
   4.209                  // yeah yeah, I know, we could be lazy here, but it looks bad.
   4.210 @@ -3189,7 +3189,7 @@
   4.211      sqlite3_bind_text(session->delete_person, 1, user_id, -1,
   4.212                        SQLITE_STATIC);
   4.213                        
   4.214 -    int result = sqlite3_step(session->delete_person);
   4.215 +    int result = Sqlite3_step(session->delete_person);
   4.216      
   4.217      if (result != SQLITE_DONE)
   4.218          status = PEP_UNKNOWN_ERROR;
   4.219 @@ -3224,7 +3224,7 @@
   4.220      sqlite3_reset(session->is_pEp_user);
   4.221      sqlite3_bind_text(session->is_pEp_user, 1, user_id, -1,
   4.222              SQLITE_STATIC);
   4.223 -    int result = sqlite3_step(session->is_pEp_user);
   4.224 +    int result = Sqlite3_step(session->is_pEp_user);
   4.225      switch (result) {
   4.226          case SQLITE_ROW: {
   4.227              // yeah yeah, I know, we could be lazy here, but it looks bad.
   4.228 @@ -3260,7 +3260,7 @@
   4.229      sqlite3_reset(session->is_own_address);
   4.230      sqlite3_bind_text(session->is_own_address, 1, address, -1,
   4.231              SQLITE_STATIC);
   4.232 -    int result = sqlite3_step(session->is_own_address);
   4.233 +    int result = Sqlite3_step(session->is_own_address);
   4.234      switch (result) {
   4.235          case SQLITE_ROW: {
   4.236              // yeah yeah, I know, we could be lazy here, but it looks bad.
   4.237 @@ -3292,7 +3292,7 @@
   4.238      sqlite3_bind_text(session->add_into_social_graph, 3, contact_ident->user_id, -1,
   4.239              SQLITE_STATIC);
   4.240          
   4.241 -    int result = sqlite3_step(session->add_into_social_graph);
   4.242 +    int result = Sqlite3_step(session->add_into_social_graph);
   4.243      sqlite3_reset(session->add_into_social_graph);
   4.244      
   4.245      if (result != SQLITE_DONE)
   4.246 @@ -3321,7 +3321,7 @@
   4.247      sqlite3_bind_text(session->get_own_address_binding_from_contact, 2, contact->user_id, -1,
   4.248              SQLITE_STATIC);
   4.249  
   4.250 -    int result = sqlite3_step(session->get_own_address_binding_from_contact);
   4.251 +    int result = Sqlite3_step(session->get_own_address_binding_from_contact);
   4.252      
   4.253      const char* own_address = NULL;
   4.254      
   4.255 @@ -3357,7 +3357,7 @@
   4.256      sqlite3_bind_text(session->remove_fpr_as_default, 1, fpr, -1,
   4.257                        SQLITE_STATIC);
   4.258  
   4.259 -    int result = sqlite3_step(session->remove_fpr_as_default);
   4.260 +    int result = Sqlite3_step(session->remove_fpr_as_default);
   4.261      sqlite3_reset(session->remove_fpr_as_default);
   4.262      
   4.263      if (result != SQLITE_DONE)
   4.264 @@ -3383,7 +3383,7 @@
   4.265      sqlite3_bind_text(session->replace_identities_fpr, 2, old_fpr, -1,
   4.266                        SQLITE_STATIC);
   4.267  
   4.268 -    int result = sqlite3_step(session->replace_identities_fpr);
   4.269 +    int result = Sqlite3_step(session->replace_identities_fpr);
   4.270      sqlite3_reset(session->replace_identities_fpr);
   4.271      
   4.272      if (result != SQLITE_DONE)
   4.273 @@ -3403,7 +3403,7 @@
   4.274      sqlite3_bind_int(session->update_trust_for_fpr, 1, comm_type);
   4.275      sqlite3_bind_text(session->update_trust_for_fpr, 2, fpr, -1,
   4.276              SQLITE_STATIC);
   4.277 -    int result = sqlite3_step(session->update_trust_for_fpr);
   4.278 +    int result = Sqlite3_step(session->update_trust_for_fpr);
   4.279      sqlite3_reset(session->update_trust_for_fpr);
   4.280      if (result != SQLITE_DONE) {
   4.281          return PEP_CANNOT_SET_TRUST;
   4.282 @@ -3435,7 +3435,7 @@
   4.283      sqlite3_bind_text(session->set_identity_flags, 3, identity->user_id, -1,
   4.284          SQLITE_STATIC);
   4.285          
   4.286 -    result = sqlite3_step(session->set_identity_flags);
   4.287 +    result = Sqlite3_step(session->set_identity_flags);
   4.288  
   4.289      sqlite3_reset(session->set_identity_flags);
   4.290      if (result != SQLITE_DONE)
   4.291 @@ -3467,7 +3467,7 @@
   4.292              SQLITE_STATIC);
   4.293      sqlite3_bind_text(session->unset_identity_flags, 3, identity->user_id, -1,
   4.294              SQLITE_STATIC);
   4.295 -    result = sqlite3_step(session->unset_identity_flags);
   4.296 +    result = Sqlite3_step(session->unset_identity_flags);
   4.297      sqlite3_reset(session->unset_identity_flags);
   4.298      if (result != SQLITE_DONE)
   4.299          return PEP_CANNOT_SET_IDENTITY;
   4.300 @@ -3491,7 +3491,7 @@
   4.301      sqlite3_reset(session->get_trust_by_userid);
   4.302      sqlite3_bind_text(session->get_trust_by_userid, 1, user_id, -1, SQLITE_STATIC);
   4.303  
   4.304 -    while ((result = sqlite3_step(session->get_trust_by_userid)) == SQLITE_ROW) {
   4.305 +    while ((result = Sqlite3_step(session->get_trust_by_userid)) == SQLITE_ROW) {
   4.306          if (!t_list)
   4.307              t_list = new_labeled_int_list(sqlite3_column_int(session->get_trust_by_userid, 1),
   4.308                                           (const char *) sqlite3_column_text(session->get_trust_by_userid, 0));
   4.309 @@ -3822,7 +3822,7 @@
   4.310              SQLITE_STATIC);
   4.311      sqlite3_bind_text(session->replace_userid, 2, old_uid, -1,
   4.312              SQLITE_STATIC);
   4.313 -    result = sqlite3_step(session->replace_userid);
   4.314 +    result = Sqlite3_step(session->replace_userid);
   4.315  #ifndef NDEBUG
   4.316      if (result) {
   4.317          const char *errmsg = sqlite3_errmsg(session->db);
   4.318 @@ -3848,7 +3848,7 @@
   4.319      sqlite3_reset(session->delete_key);
   4.320      sqlite3_bind_text(session->delete_key, 1, fpr, -1,
   4.321              SQLITE_STATIC);
   4.322 -    result = sqlite3_step(session->delete_key);
   4.323 +    result = Sqlite3_step(session->delete_key);
   4.324      sqlite3_reset(session->delete_key);
   4.325      if (result != SQLITE_DONE)
   4.326          return PEP_CANNOT_SET_PGP_KEYPAIR;
   4.327 @@ -3869,7 +3869,7 @@
   4.328      sqlite3_reset(session->refresh_userid_default_key);
   4.329      sqlite3_bind_text(session->refresh_userid_default_key, 1, user_id, -1,
   4.330              SQLITE_STATIC);
   4.331 -    result = sqlite3_step(session->refresh_userid_default_key);
   4.332 +    result = Sqlite3_step(session->refresh_userid_default_key);
   4.333      sqlite3_reset(session->refresh_userid_default_key);
   4.334      if (result != SQLITE_DONE)
   4.335          return PEP_CANNOT_SET_PERSON;
   4.336 @@ -3893,7 +3893,7 @@
   4.337              SQLITE_STATIC);
   4.338      sqlite3_bind_text(session->replace_main_user_fpr, 2, user_id, -1,
   4.339              SQLITE_STATIC);
   4.340 -    result = sqlite3_step(session->replace_main_user_fpr);
   4.341 +    result = Sqlite3_step(session->replace_main_user_fpr);
   4.342      sqlite3_reset(session->replace_main_user_fpr);
   4.343      if (result != SQLITE_DONE)
   4.344          return PEP_CANNOT_SET_PERSON;
   4.345 @@ -3920,7 +3920,7 @@
   4.346      sqlite3_reset(session->get_main_user_fpr);
   4.347      sqlite3_bind_text(session->get_main_user_fpr, 1, user_id, -1,
   4.348                        SQLITE_STATIC);
   4.349 -    result = sqlite3_step(session->get_main_user_fpr);
   4.350 +    result = Sqlite3_step(session->get_main_user_fpr);
   4.351      switch (result) {
   4.352      case SQLITE_ROW: {
   4.353          const char* _fpr = 
   4.354 @@ -3968,7 +3968,7 @@
   4.355      sqlite3_reset(session->mark_compromised);
   4.356      sqlite3_bind_text(session->mark_compromised, 1, fpr, -1,
   4.357              SQLITE_STATIC);
   4.358 -    result = sqlite3_step(session->mark_compromised);
   4.359 +    result = Sqlite3_step(session->mark_compromised);
   4.360      sqlite3_reset(session->mark_compromised);
   4.361  
   4.362      if (result != SQLITE_DONE)
   4.363 @@ -4008,7 +4008,7 @@
   4.364              SQLITE_STATIC);
   4.365      sqlite3_bind_text(session->get_trust, 2, identity->fpr, -1, SQLITE_STATIC);
   4.366  
   4.367 -    result = sqlite3_step(session->get_trust);
   4.368 +    result = Sqlite3_step(session->get_trust);
   4.369      switch (result) {
   4.370      case SQLITE_ROW: {
   4.371          int comm_type = (PEP_comm_type) sqlite3_column_int(session->get_trust,
   4.372 @@ -4047,7 +4047,7 @@
   4.373      sqlite3_reset(session->least_trust);
   4.374      sqlite3_bind_text(session->least_trust, 1, fpr, -1, SQLITE_STATIC);
   4.375  
   4.376 -    result = sqlite3_step(session->least_trust);
   4.377 +    result = Sqlite3_step(session->least_trust);
   4.378      switch (result) {
   4.379          case SQLITE_ROW: {
   4.380              int _comm_type = sqlite3_column_int(session->least_trust, 0);
   4.381 @@ -4478,7 +4478,7 @@
   4.382      int result;
   4.383  
   4.384      do {
   4.385 -        result = sqlite3_step(session->crashdump);
   4.386 +        result = Sqlite3_step(session->crashdump);
   4.387          switch (result) {
   4.388          case SQLITE_ROW:
   4.389              timestamp = (const char *) sqlite3_column_text(session->crashdump,
   4.390 @@ -4570,7 +4570,7 @@
   4.391      int result;
   4.392  
   4.393      do {
   4.394 -        result = sqlite3_step(session->languagelist);
   4.395 +        result = Sqlite3_step(session->languagelist);
   4.396          switch (result) {
   4.397          case SQLITE_ROW:
   4.398              lang = (const char *) sqlite3_column_text(session->languagelist,
   4.399 @@ -4638,7 +4638,7 @@
   4.400      const char *_phrase = NULL;
   4.401      int result;
   4.402  
   4.403 -    result = sqlite3_step(session->i18n_token);
   4.404 +    result = Sqlite3_step(session->i18n_token);
   4.405      switch (result) {
   4.406      case SQLITE_ROW:
   4.407          _phrase = (const char *) sqlite3_column_text(session->i18n_token, 0);
   4.408 @@ -4680,7 +4680,7 @@
   4.409      sqlite3_reset(session->sequence_value2);
   4.410      sqlite3_bind_text(session->sequence_value2, 1, name, -1,
   4.411              SQLITE_STATIC);
   4.412 -    int result = sqlite3_step(session->sequence_value2);
   4.413 +    int result = Sqlite3_step(session->sequence_value2);
   4.414      switch (result) {
   4.415          case SQLITE_ROW: {
   4.416              int32_t _value = (int32_t)
   4.417 @@ -4708,7 +4708,7 @@
   4.418  
   4.419      sqlite3_reset(session->sequence_value1);
   4.420      sqlite3_bind_text(session->sequence_value1, 1, name, -1, SQLITE_STATIC);
   4.421 -    int result = sqlite3_step(session->sequence_value1);
   4.422 +    int result = Sqlite3_step(session->sequence_value1);
   4.423      assert(result == SQLITE_DONE);
   4.424      sqlite3_reset(session->sequence_value1);
   4.425      if (result == SQLITE_DONE)
   4.426 @@ -4769,7 +4769,7 @@
   4.427      
   4.428      sqlite3_bind_text(session->own_key_is_listed, 1, fpr, -1,
   4.429              SQLITE_STATIC);
   4.430 -    int result = sqlite3_step(session->own_key_is_listed);
   4.431 +    int result = Sqlite3_step(session->own_key_is_listed);
   4.432      switch (result) {
   4.433          case SQLITE_ROW: {
   4.434              *own_key = (sqlite3_column_int(session->own_key_is_listed, 0) != 0);
   4.435 @@ -4813,7 +4813,7 @@
   4.436  
   4.437      int result;
   4.438      
   4.439 -    result = sqlite3_step(session->set_revoked);
   4.440 +    result = Sqlite3_step(session->set_revoked);
   4.441      switch (result) {
   4.442          case SQLITE_DONE:
   4.443              status = PEP_STATUS_OK;
   4.444 @@ -4855,7 +4855,7 @@
   4.445  
   4.446      int result;
   4.447      
   4.448 -    result = sqlite3_step(session->get_revoked);
   4.449 +    result = Sqlite3_step(session->get_revoked);
   4.450      switch (result) {
   4.451          case SQLITE_ROW: {
   4.452              *revoked_fpr = strdup((const char *)
   4.453 @@ -4899,7 +4899,7 @@
   4.454  
   4.455      int result;
   4.456      
   4.457 -    result = sqlite3_step(session->get_replacement_fpr);
   4.458 +    result = Sqlite3_step(session->get_replacement_fpr);
   4.459      switch (result) {
   4.460          case SQLITE_ROW: {
   4.461              *revoked_fpr = strdup((const char *)
   4.462 @@ -4938,7 +4938,7 @@
   4.463      sqlite3_reset(session->get_last_contacted);
   4.464      int result;
   4.465  
   4.466 -    while ((result = sqlite3_step(session->get_last_contacted)) == SQLITE_ROW) {
   4.467 +    while ((result = Sqlite3_step(session->get_last_contacted)) == SQLITE_ROW) {
   4.468          pEp_identity *ident = new_identity(
   4.469                  (const char *) sqlite3_column_text(session->get_last_contacted, 1),
   4.470                  NULL,
     5.1 --- a/src/pEp_internal.h	Mon May 20 14:49:40 2019 +0200
     5.2 +++ b/src/pEp_internal.h	Tue May 21 07:04:51 2019 +0200
     5.3 @@ -475,3 +475,15 @@
     5.4      _pEp_rand_max_bits = (int) ceil(log2((double) RAND_MAX));
     5.5      _pEp_log2_36 = log2(36);
     5.6  }
     5.7 +
     5.8 +// spinlock implementation
     5.9 +
    5.10 +static inline int Sqlite3_step(sqlite3_stmt* stmt)
    5.11 +{
    5.12 +    int rc;
    5.13 +    do {
    5.14 +        rc = sqlite3_step(stmt);
    5.15 +    } while (rc == SQLITE_BUSY || rc == SQLITE_LOCKED);
    5.16 +    return rc;
    5.17 +}
    5.18 +
     6.1 --- a/src/pgp_sequoia.c	Mon May 20 14:49:40 2019 +0200
     6.2 +++ b/src/pgp_sequoia.c	Tue May 21 07:04:51 2019 +0200
     6.3 @@ -446,7 +446,7 @@
     6.4                             pgp_tpk_t *tpkp, int *secretp)
     6.5  {
     6.6      PEP_STATUS status = PEP_STATUS_OK;
     6.7 -    int sqlite_result = sqlite3_step(stmt);
     6.8 +    int sqlite_result = Sqlite3_step(stmt);
     6.9      switch (sqlite_result) {
    6.10      case SQLITE_ROW:
    6.11          if (tpkp) {
    6.12 @@ -692,7 +692,7 @@
    6.13      char *name = NULL;
    6.14  
    6.15      sqlite3_stmt *stmt = session->sq_sql.begin_transaction;
    6.16 -    int sqlite_result = sqlite3_step(stmt);
    6.17 +    int sqlite_result = Sqlite3_step(stmt);
    6.18      sqlite3_reset(stmt);
    6.19      if (sqlite_result != SQLITE_DONE)
    6.20          ERROR_OUT(NULL, PEP_UNKNOWN_ERROR,
    6.21 @@ -738,7 +738,7 @@
    6.22      sqlite3_bind_int(stmt, 2, is_tsk);
    6.23      sqlite3_bind_blob(stmt, 3, tsk_buffer, tsk_buffer_len, SQLITE_STATIC);
    6.24  
    6.25 -    sqlite_result = sqlite3_step(stmt);
    6.26 +    sqlite_result = Sqlite3_step(stmt);
    6.27      sqlite3_reset(stmt);
    6.28      if (sqlite_result != SQLITE_DONE)
    6.29          ERROR_OUT(NULL, PEP_UNKNOWN_ERROR,
    6.30 @@ -756,7 +756,7 @@
    6.31          sqlite3_bind_text(stmt, 1, keyid_hex, -1, SQLITE_STATIC);
    6.32          sqlite3_bind_text(stmt, 2, fpr, -1, SQLITE_STATIC);
    6.33  
    6.34 -        sqlite_result = sqlite3_step(stmt);
    6.35 +        sqlite_result = Sqlite3_step(stmt);
    6.36          sqlite3_reset(stmt);
    6.37          free(keyid_hex);
    6.38          pgp_keyid_free(keyid);
    6.39 @@ -846,7 +846,7 @@
    6.40              sqlite3_bind_text(stmt, 1, email, -1, SQLITE_STATIC);
    6.41              sqlite3_bind_text(stmt, 2, fpr, -1, SQLITE_STATIC);
    6.42  
    6.43 -            sqlite_result = sqlite3_step(stmt);
    6.44 +            sqlite_result = Sqlite3_step(stmt);
    6.45              sqlite3_reset(stmt);
    6.46  
    6.47              if (sqlite_result != SQLITE_DONE) {
    6.48 @@ -880,7 +880,7 @@
    6.49          stmt = status == PEP_STATUS_OK
    6.50              ? session->sq_sql.commit_transaction
    6.51              : session->sq_sql.rollback_transaction;
    6.52 -        int sqlite_result = sqlite3_step(stmt);
    6.53 +        int sqlite_result = Sqlite3_step(stmt);
    6.54          sqlite3_reset(stmt);
    6.55          if (sqlite_result != SQLITE_DONE)
    6.56              ERROR_OUT(NULL, PEP_UNKNOWN_ERROR,
     7.1 --- a/sync/sql_func.yml2	Mon May 20 14:49:40 2019 +0200
     7.2 +++ b/sync/sql_func.yml2	Tue May 21 07:04:51 2019 +0200
     7.3 @@ -31,7 +31,7 @@
     7.4      call "init_sql" with "sql", "$sql";
     7.5      ||
     7.6          int _result = 0;
     7.7 -        int_result = sqlite3_step(_sql);
     7.8 +        int_result = Sqlite3_step(_sql);
     7.9          assert(int_result == SQLITE_ROW);
    7.10          if (int_result == SQLITE_ROW)
    7.11              _result = sqlite3_column_int(_sql, 0);