Browse Source

spinlock implementation for dealing with write locks

ENGINE-641
Volker Birk 3 years ago
parent
commit
d4f11f8257
7 changed files with 85 additions and 73 deletions
  1. +4
    -4
      src/blacklist.c
  2. +2
    -2
      src/key_reset.c
  3. +8
    -8
      src/keymanagement.c
  4. +52
    -52
      src/pEpEngine.c
  5. +12
    -0
      src/pEp_internal.h
  6. +6
    -6
      src/pgp_sequoia.c
  7. +1
    -1
      sync/sql_func.yml2

+ 4
- 4
src/blacklist.c View File

@ -20,7 +20,7 @@ DYNAMIC_API PEP_STATUS blacklist_add(PEP_SESSION session, const char *fpr)
int result;
result = sqlite3_step(session->blacklist_add);
result = Sqlite3_step(session->blacklist_add);
switch (result) {
case SQLITE_DONE:
status = PEP_STATUS_OK;
@ -50,7 +50,7 @@ DYNAMIC_API PEP_STATUS blacklist_delete(PEP_SESSION session, const char *fpr)
int result;
result = sqlite3_step(session->blacklist_delete);
result = Sqlite3_step(session->blacklist_delete);
switch (result) {
case SQLITE_DONE:
status = PEP_STATUS_OK;
@ -85,7 +85,7 @@ DYNAMIC_API PEP_STATUS blacklist_is_listed(
int result;
result = sqlite3_step(session->blacklist_is_listed);
result = Sqlite3_step(session->blacklist_is_listed);
switch (result) {
case SQLITE_ROW:
count = sqlite3_column_int(session->blacklist_is_listed, 0);
@ -125,7 +125,7 @@ DYNAMIC_API PEP_STATUS blacklist_retrieve(
stringlist_t *_bl = _blacklist;
do {
result = sqlite3_step(session->blacklist_retrieve);
result = Sqlite3_step(session->blacklist_retrieve);
switch (result) {
case SQLITE_ROW:
{


+ 2
- 2
src/key_reset.c View File

@ -39,7 +39,7 @@ PEP_STATUS has_key_reset_been_sent(
SQLITE_STATIC);
sqlite3_bind_text(session->was_id_for_revoke_contacted, 2, user_id, -1,
SQLITE_STATIC);
int result = sqlite3_step(session->was_id_for_revoke_contacted);
int result = Sqlite3_step(session->was_id_for_revoke_contacted);
switch (result) {
case SQLITE_ROW: {
*contacted = (sqlite3_column_int(session->was_id_for_revoke_contacted, 0) != 0);
@ -79,7 +79,7 @@ PEP_STATUS set_reset_contact_notified(
int result;
result = sqlite3_step(session->set_revoke_contact_as_notified);
result = Sqlite3_step(session->set_revoke_contact_as_notified);
switch (result) {
case SQLITE_DONE:
status = PEP_STATUS_OK;


+ 8
- 8
src/keymanagement.c View File

@ -282,7 +282,7 @@ PEP_STATUS get_all_keys_for_user(PEP_SESSION session,
int result = -1;
while ((result = sqlite3_step(session->get_all_keys_for_user)) == SQLITE_ROW) {
while ((result = Sqlite3_step(session->get_all_keys_for_user)) == SQLITE_ROW) {
const char* keyres = (const char *) sqlite3_column_text(session->get_all_keys_for_user, 0);
if (keyres) {
if (_kl)
@ -317,7 +317,7 @@ PEP_STATUS get_user_default_key(PEP_SESSION session, const char* user_id,
sqlite3_bind_text(session->get_user_default_key, 1, user_id,
-1, SQLITE_STATIC);
const int result = sqlite3_step(session->get_user_default_key);
const int result = Sqlite3_step(session->get_user_default_key);
char* user_fpr = NULL;
if (result == SQLITE_ROW) {
const char* u_fpr =
@ -1621,7 +1621,7 @@ DYNAMIC_API PEP_STATUS own_key_is_listed(
int result;
result = sqlite3_step(session->own_key_is_listed);
result = Sqlite3_step(session->own_key_is_listed);
switch (result) {
case SQLITE_ROW:
count = sqlite3_column_int(session->own_key_is_listed, 0);
@ -1671,7 +1671,7 @@ PEP_STATUS _own_identities_retrieve(
sqlite3_bind_int(session->own_identities_retrieve, 1, excluded_flags);
do {
result = sqlite3_step(session->own_identities_retrieve);
result = Sqlite3_step(session->own_identities_retrieve);
switch (result) {
case SQLITE_ROW:
address = (const char *)
@ -1765,7 +1765,7 @@ PEP_STATUS _own_keys_retrieve(
sqlite3_bind_int(session->own_keys_retrieve, 1, excluded_flags);
do {
result = sqlite3_step(session->own_keys_retrieve);
result = Sqlite3_step(session->own_keys_retrieve);
switch (result) {
case SQLITE_ROW:
_bl = stringlist_add(_bl, (const char *)
@ -1906,7 +1906,7 @@ PEP_STATUS add_mistrusted_key(PEP_SESSION session, const char* fpr)
sqlite3_bind_text(session->add_mistrusted_key, 1, fpr, -1,
SQLITE_STATIC);
result = sqlite3_step(session->add_mistrusted_key);
result = Sqlite3_step(session->add_mistrusted_key);
sqlite3_reset(session->add_mistrusted_key);
if (result != SQLITE_DONE)
@ -1928,7 +1928,7 @@ PEP_STATUS delete_mistrusted_key(PEP_SESSION session, const char* fpr)
sqlite3_bind_text(session->delete_mistrusted_key, 1, fpr, -1,
SQLITE_STATIC);
result = sqlite3_step(session->delete_mistrusted_key);
result = Sqlite3_step(session->delete_mistrusted_key);
sqlite3_reset(session->delete_mistrusted_key);
if (result != SQLITE_DONE)
@ -1955,7 +1955,7 @@ PEP_STATUS is_mistrusted_key(PEP_SESSION session, const char* fpr,
int result;
result = sqlite3_step(session->is_mistrusted_key);
result = Sqlite3_step(session->is_mistrusted_key);
switch (result) {
case SQLITE_ROW:
*mistrusted = sqlite3_column_int(session->is_mistrusted_key, 0);


+ 52
- 52
src/pEpEngine.c View File

@ -533,7 +533,7 @@ static int db_contains_table(PEP_SESSION session, const char* table_name) {
int retval = 0;
int rc = sqlite3_step(stmt);
int rc = Sqlite3_step(stmt);
if (rc == SQLITE_DONE || rc == SQLITE_OK || rc == SQLITE_ROW) {
retval = 1;
}
@ -584,7 +584,7 @@ static int table_contains_column(PEP_SESSION session, const char* table_name,
int retval = 0;
int rc = sqlite3_step(stmt);
int rc = Sqlite3_step(stmt);
if (rc == SQLITE_DONE || rc == SQLITE_OK || rc == SQLITE_ROW) {
retval = 1;
}
@ -607,7 +607,7 @@ PEP_STATUS repair_altered_tables(PEP_SESSION session) {
sqlite3_prepare_v2(session->db, sql_query, -1, &stmt, NULL);
int i = 0;
int int_result = 0;
while ((int_result = sqlite3_step(stmt)) == SQLITE_ROW && i < _PEP_MAX_AFFECTED) {
while ((int_result = Sqlite3_step(stmt)) == SQLITE_ROW && i < _PEP_MAX_AFFECTED) {
table_names[i++] = strdup((const char*)(sqlite3_column_text(stmt, 0)));
}
@ -2040,7 +2040,7 @@ DYNAMIC_API PEP_STATUS log_event(
// sqlite3_bind_text(session->log, 4, comment, -1, SQLITE_STATIC);
// else
// sqlite3_bind_null(session->log, 4);
// result = sqlite3_step(session->log);
// result = Sqlite3_step(session->log);
// sqlite3_reset(session->log);
//
return PEP_STATUS_OK; // We ignore errors for this function.
@ -2094,7 +2094,7 @@ DYNAMIC_API PEP_STATUS trustword(
sqlite3_bind_text(session->trustword, 1, lang, -1, SQLITE_STATIC);
sqlite3_bind_int(session->trustword, 2, value);
const int result = sqlite3_step(session->trustword);
const int result = Sqlite3_step(session->trustword);
if (result == SQLITE_ROW) {
*word = strdup((const char *) sqlite3_column_text(session->trustword,
1));
@ -2289,7 +2289,7 @@ DYNAMIC_API PEP_STATUS get_default_own_userid(
sqlite3_reset(session->get_default_own_userid);
const int result = sqlite3_step(session->get_default_own_userid);
const int result = Sqlite3_step(session->get_default_own_userid);
const char* id;
switch (result) {
@ -2338,7 +2338,7 @@ DYNAMIC_API PEP_STATUS get_userid_alias_default(
const char* tempid;
const int result = sqlite3_step(session->get_userid_alias_default);
const int result = Sqlite3_step(session->get_userid_alias_default);
switch (result) {
case SQLITE_ROW:
tempid = (const char *) sqlite3_column_text(session->get_userid_alias_default, 0);
@ -2383,7 +2383,7 @@ DYNAMIC_API PEP_STATUS set_userid_alias (
sqlite3_bind_text(session->add_userid_alias, 2, alias_id, -1,
SQLITE_STATIC);
result = sqlite3_step(session->add_userid_alias);
result = Sqlite3_step(session->add_userid_alias);
sqlite3_reset(session->add_userid_alias);
if (result != SQLITE_DONE) {
@ -2420,7 +2420,7 @@ DYNAMIC_API PEP_STATUS get_identity(
sqlite3_bind_text(session->get_identity, 1, address, -1, SQLITE_STATIC);
sqlite3_bind_text(session->get_identity, 2, user_id, -1, SQLITE_STATIC);
const int result = sqlite3_step(session->get_identity);
const int result = Sqlite3_step(session->get_identity);
switch (result) {
case SQLITE_ROW:
_identity = new_identity(
@ -2483,7 +2483,7 @@ PEP_STATUS get_identities_by_userid(
sqlite3_bind_text(session->get_identities_by_userid, 1, user_id, -1, SQLITE_STATIC);
int result = -1;
while ((result = sqlite3_step(session->get_identities_by_userid)) == SQLITE_ROW) {
while ((result = Sqlite3_step(session->get_identities_by_userid)) == SQLITE_ROW) {
// "select address, fpr, username, comm_type, lang,"
// " identity.flags | pgp_keypair.flags,"
// " is_own"
@ -2561,7 +2561,7 @@ PEP_STATUS get_identities_by_main_key_id(
int result = -1;
while ((result = sqlite3_step(session->get_identities_by_main_key_id)) == SQLITE_ROW) {
while ((result = Sqlite3_step(session->get_identities_by_main_key_id)) == SQLITE_ROW) {
ident = new_identity(
(const char *) sqlite3_column_text(session->get_identities_by_main_key_id, 0),
fpr,
@ -2631,7 +2631,7 @@ PEP_STATUS get_identity_without_trust_check(
sqlite3_bind_text(session->get_identity_without_trust_check, 1, address, -1, SQLITE_STATIC);
sqlite3_bind_text(session->get_identity_without_trust_check, 2, user_id, -1, SQLITE_STATIC);
const int result = sqlite3_step(session->get_identity_without_trust_check);
const int result = Sqlite3_step(session->get_identity_without_trust_check);
switch (result) {
case SQLITE_ROW:
_identity = new_identity(
@ -2695,7 +2695,7 @@ PEP_STATUS get_identities_by_address(
sqlite3_bind_text(session->get_identities_by_address, 1, address, -1, SQLITE_STATIC);
int result;
while ((result = sqlite3_step(session->get_identities_by_address)) == SQLITE_ROW) {
while ((result = Sqlite3_step(session->get_identities_by_address)) == SQLITE_ROW) {
//"select user_id, main_key_id, username, comm_type, lang,"
//" identity.flags, is_own"
pEp_identity *ident = new_identity(
@ -2762,7 +2762,7 @@ PEP_STATUS exists_identity_entry(PEP_SESSION session, pEp_identity* identity,
sqlite3_bind_text(session->exists_identity_entry, 2, identity->user_id, -1,
SQLITE_STATIC);
int result = sqlite3_step(session->exists_identity_entry);
int result = Sqlite3_step(session->exists_identity_entry);
switch (result) {
case SQLITE_ROW: {
@ -2797,7 +2797,7 @@ PEP_STATUS exists_trust_entry(PEP_SESSION session, pEp_identity* identity,
sqlite3_bind_text(session->exists_trust_entry, 2, identity->fpr, -1,
SQLITE_STATIC);
int result = sqlite3_step(session->exists_trust_entry);
int result = Sqlite3_step(session->exists_trust_entry);
switch (result) {
case SQLITE_ROW: {
// yeah yeah, I know, we could be lazy here, but it looks bad.
@ -2821,7 +2821,7 @@ PEP_STATUS set_pgp_keypair(PEP_SESSION session, const char* fpr) {
sqlite3_reset(session->set_pgp_keypair);
sqlite3_bind_text(session->set_pgp_keypair, 1, fpr, -1,
SQLITE_STATIC);
result = sqlite3_step(session->set_pgp_keypair);
result = Sqlite3_step(session->set_pgp_keypair);
sqlite3_reset(session->set_pgp_keypair);
if (result != SQLITE_DONE) {
return PEP_CANNOT_SET_PGP_KEYPAIR;
@ -2854,7 +2854,7 @@ static PEP_STATUS _set_or_update_trust(PEP_SESSION session,
sqlite3_bind_text(set_or_update, 2, identity->fpr, -1,
SQLITE_STATIC);
sqlite3_bind_int(set_or_update, 3, identity->comm_type);
result = sqlite3_step(set_or_update);
result = Sqlite3_step(set_or_update);
assert(result == SQLITE_DONE);
sqlite3_reset(set_or_update);
if (result != SQLITE_DONE)
@ -2882,7 +2882,7 @@ static PEP_STATUS _set_or_update_identity_entry(PEP_SESSION session,
SQLITE_STATIC);
sqlite3_bind_int(set_or_update, 4, identity->flags);
sqlite3_bind_int(set_or_update, 5, identity->me);
int result = sqlite3_step(set_or_update);
int result = Sqlite3_step(set_or_update);
sqlite3_reset(set_or_update);
if (result != SQLITE_DONE)
return PEP_CANNOT_SET_IDENTITY;
@ -2912,7 +2912,7 @@ static PEP_STATUS _set_or_update_person(PEP_SESSION session,
sqlite3_bind_null(set_or_update, 3);
sqlite3_bind_text(set_or_update, 4, identity->fpr, -1,
SQLITE_STATIC);
int result = sqlite3_step(set_or_update);
int result = Sqlite3_step(set_or_update);
sqlite3_reset(set_or_update);
if (result != SQLITE_DONE)
@ -3028,7 +3028,7 @@ DYNAMIC_API PEP_STATUS set_identity(
sqlite3_reset(session->set_pgp_keypair);
sqlite3_bind_text(session->set_pgp_keypair, 1, identity->fpr, -1,
SQLITE_STATIC);
result = sqlite3_step(session->set_pgp_keypair);
result = Sqlite3_step(session->set_pgp_keypair);
sqlite3_reset(session->set_pgp_keypair);
if (result != SQLITE_DONE) {
sqlite3_exec(session->db, "ROLLBACK ;", NULL, NULL, NULL);
@ -3081,7 +3081,7 @@ PEP_STATUS update_pEp_user_trust_vals(PEP_SESSION session,
sqlite3_reset(session->update_trust_to_pEp);
sqlite3_bind_text(session->update_trust_to_pEp, 1, user->user_id, -1,
SQLITE_STATIC);
int result = sqlite3_step(session->update_trust_to_pEp);
int result = Sqlite3_step(session->update_trust_to_pEp);
sqlite3_reset(session->update_trust_to_pEp);
if (result != SQLITE_DONE)
return PEP_CANNOT_SET_TRUST;
@ -3116,7 +3116,7 @@ DYNAMIC_API PEP_STATUS set_as_pEp_user(PEP_SESSION session, pEp_identity* user)
sqlite3_reset(session->set_as_pEp_user);
sqlite3_bind_text(session->set_as_pEp_user, 1, user->user_id, -1,
SQLITE_STATIC);
int result = sqlite3_step(session->set_as_pEp_user);
int result = Sqlite3_step(session->set_as_pEp_user);
sqlite3_reset(session->set_as_pEp_user);
if (result != SQLITE_DONE)
@ -3151,7 +3151,7 @@ PEP_STATUS exists_person(PEP_SESSION session, pEp_identity* identity,
sqlite3_reset(session->exists_person);
sqlite3_bind_text(session->exists_person, 1, user_id, -1,
SQLITE_STATIC);
int result = sqlite3_step(session->exists_person);
int result = Sqlite3_step(session->exists_person);
switch (result) {
case SQLITE_ROW: {
// yeah yeah, I know, we could be lazy here, but it looks bad.
@ -3189,7 +3189,7 @@ PEP_STATUS delete_person(PEP_SESSION session, const char* user_id) {
sqlite3_bind_text(session->delete_person, 1, user_id, -1,
SQLITE_STATIC);
int result = sqlite3_step(session->delete_person);
int result = Sqlite3_step(session->delete_person);
if (result != SQLITE_DONE)
status = PEP_UNKNOWN_ERROR;
@ -3224,7 +3224,7 @@ DYNAMIC_API PEP_STATUS is_pEp_user(PEP_SESSION session, pEp_identity *identity,
sqlite3_reset(session->is_pEp_user);
sqlite3_bind_text(session->is_pEp_user, 1, user_id, -1,
SQLITE_STATIC);
int result = sqlite3_step(session->is_pEp_user);
int result = Sqlite3_step(session->is_pEp_user);
switch (result) {
case SQLITE_ROW: {
// yeah yeah, I know, we could be lazy here, but it looks bad.
@ -3260,7 +3260,7 @@ PEP_STATUS is_own_address(PEP_SESSION session, const char* address, bool* is_own
sqlite3_reset(session->is_own_address);
sqlite3_bind_text(session->is_own_address, 1, address, -1,
SQLITE_STATIC);
int result = sqlite3_step(session->is_own_address);
int result = Sqlite3_step(session->is_own_address);
switch (result) {
case SQLITE_ROW: {
// yeah yeah, I know, we could be lazy here, but it looks bad.
@ -3292,7 +3292,7 @@ PEP_STATUS bind_own_ident_with_contact_ident(PEP_SESSION session,
sqlite3_bind_text(session->add_into_social_graph, 3, contact_ident->user_id, -1,
SQLITE_STATIC);
int result = sqlite3_step(session->add_into_social_graph);
int result = Sqlite3_step(session->add_into_social_graph);
sqlite3_reset(session->add_into_social_graph);
if (result != SQLITE_DONE)
@ -3321,7 +3321,7 @@ PEP_STATUS get_own_ident_for_contact_id(PEP_SESSION session,
sqlite3_bind_text(session->get_own_address_binding_from_contact, 2, contact->user_id, -1,
SQLITE_STATIC);
int result = sqlite3_step(session->get_own_address_binding_from_contact);
int result = Sqlite3_step(session->get_own_address_binding_from_contact);
const char* own_address = NULL;
@ -3357,7 +3357,7 @@ PEP_STATUS remove_fpr_as_default(PEP_SESSION session,
sqlite3_bind_text(session->remove_fpr_as_default, 1, fpr, -1,
SQLITE_STATIC);
int result = sqlite3_step(session->remove_fpr_as_default);
int result = Sqlite3_step(session->remove_fpr_as_default);
sqlite3_reset(session->remove_fpr_as_default);
if (result != SQLITE_DONE)
@ -3383,7 +3383,7 @@ PEP_STATUS replace_identities_fpr(PEP_SESSION session,
sqlite3_bind_text(session->replace_identities_fpr, 2, old_fpr, -1,
SQLITE_STATIC);
int result = sqlite3_step(session->replace_identities_fpr);
int result = Sqlite3_step(session->replace_identities_fpr);
sqlite3_reset(session->replace_identities_fpr);
if (result != SQLITE_DONE)
@ -3403,7 +3403,7 @@ PEP_STATUS update_trust_for_fpr(PEP_SESSION session,
sqlite3_bind_int(session->update_trust_for_fpr, 1, comm_type);
sqlite3_bind_text(session->update_trust_for_fpr, 2, fpr, -1,
SQLITE_STATIC);
int result = sqlite3_step(session->update_trust_for_fpr);
int result = Sqlite3_step(session->update_trust_for_fpr);
sqlite3_reset(session->update_trust_for_fpr);
if (result != SQLITE_DONE) {
return PEP_CANNOT_SET_TRUST;
@ -3435,7 +3435,7 @@ DYNAMIC_API PEP_STATUS set_identity_flags(
sqlite3_bind_text(session->set_identity_flags, 3, identity->user_id, -1,
SQLITE_STATIC);
result = sqlite3_step(session->set_identity_flags);
result = Sqlite3_step(session->set_identity_flags);
sqlite3_reset(session->set_identity_flags);
if (result != SQLITE_DONE)
@ -3467,7 +3467,7 @@ DYNAMIC_API PEP_STATUS unset_identity_flags(
SQLITE_STATIC);
sqlite3_bind_text(session->unset_identity_flags, 3, identity->user_id, -1,
SQLITE_STATIC);
result = sqlite3_step(session->unset_identity_flags);
result = Sqlite3_step(session->unset_identity_flags);
sqlite3_reset(session->unset_identity_flags);
if (result != SQLITE_DONE)
return PEP_CANNOT_SET_IDENTITY;
@ -3491,7 +3491,7 @@ PEP_STATUS get_trust_by_userid(PEP_SESSION session, const char* user_id,
sqlite3_reset(session->get_trust_by_userid);
sqlite3_bind_text(session->get_trust_by_userid, 1, user_id, -1, SQLITE_STATIC);
while ((result = sqlite3_step(session->get_trust_by_userid)) == SQLITE_ROW) {
while ((result = Sqlite3_step(session->get_trust_by_userid)) == SQLITE_ROW) {
if (!t_list)
t_list = new_labeled_int_list(sqlite3_column_int(session->get_trust_by_userid, 1),
(const char *) sqlite3_column_text(session->get_trust_by_userid, 0));
@ -3822,7 +3822,7 @@ PEP_STATUS replace_userid(PEP_SESSION session, const char* old_uid,
SQLITE_STATIC);
sqlite3_bind_text(session->replace_userid, 2, old_uid, -1,
SQLITE_STATIC);
result = sqlite3_step(session->replace_userid);
result = Sqlite3_step(session->replace_userid);
#ifndef NDEBUG
if (result) {
const char *errmsg = sqlite3_errmsg(session->db);
@ -3848,7 +3848,7 @@ PEP_STATUS remove_key(PEP_SESSION session, const char* fpr) {
sqlite3_reset(session->delete_key);
sqlite3_bind_text(session->delete_key, 1, fpr, -1,
SQLITE_STATIC);
result = sqlite3_step(session->delete_key);
result = Sqlite3_step(session->delete_key);
sqlite3_reset(session->delete_key);
if (result != SQLITE_DONE)
return PEP_CANNOT_SET_PGP_KEYPAIR;
@ -3869,7 +3869,7 @@ PEP_STATUS refresh_userid_default_key(PEP_SESSION session, const char* user_id)
sqlite3_reset(session->refresh_userid_default_key);
sqlite3_bind_text(session->refresh_userid_default_key, 1, user_id, -1,
SQLITE_STATIC);
result = sqlite3_step(session->refresh_userid_default_key);
result = Sqlite3_step(session->refresh_userid_default_key);
sqlite3_reset(session->refresh_userid_default_key);
if (result != SQLITE_DONE)
return PEP_CANNOT_SET_PERSON;
@ -3893,7 +3893,7 @@ PEP_STATUS replace_main_user_fpr(PEP_SESSION session, const char* user_id,
SQLITE_STATIC);
sqlite3_bind_text(session->replace_main_user_fpr, 2, user_id, -1,
SQLITE_STATIC);
result = sqlite3_step(session->replace_main_user_fpr);
result = Sqlite3_step(session->replace_main_user_fpr);
sqlite3_reset(session->replace_main_user_fpr);
if (result != SQLITE_DONE)
return PEP_CANNOT_SET_PERSON;
@ -3920,7 +3920,7 @@ PEP_STATUS get_main_user_fpr(PEP_SESSION session,
sqlite3_reset(session->get_main_user_fpr);
sqlite3_bind_text(session->get_main_user_fpr, 1, user_id, -1,
SQLITE_STATIC);
result = sqlite3_step(session->get_main_user_fpr);
result = Sqlite3_step(session->get_main_user_fpr);
switch (result) {
case SQLITE_ROW: {
const char* _fpr =
@ -3968,7 +3968,7 @@ DYNAMIC_API PEP_STATUS mark_as_compromised(
sqlite3_reset(session->mark_compromised);
sqlite3_bind_text(session->mark_compromised, 1, fpr, -1,
SQLITE_STATIC);
result = sqlite3_step(session->mark_compromised);
result = Sqlite3_step(session->mark_compromised);
sqlite3_reset(session->mark_compromised);
if (result != SQLITE_DONE)
@ -4008,7 +4008,7 @@ DYNAMIC_API PEP_STATUS get_trust(PEP_SESSION session, pEp_identity *identity)
SQLITE_STATIC);
sqlite3_bind_text(session->get_trust, 2, identity->fpr, -1, SQLITE_STATIC);
result = sqlite3_step(session->get_trust);
result = Sqlite3_step(session->get_trust);
switch (result) {
case SQLITE_ROW: {
int comm_type = (PEP_comm_type) sqlite3_column_int(session->get_trust,
@ -4047,7 +4047,7 @@ DYNAMIC_API PEP_STATUS least_trust(
sqlite3_reset(session->least_trust);
sqlite3_bind_text(session->least_trust, 1, fpr, -1, SQLITE_STATIC);
result = sqlite3_step(session->least_trust);
result = Sqlite3_step(session->least_trust);
switch (result) {
case SQLITE_ROW: {
int _comm_type = sqlite3_column_int(session->least_trust, 0);
@ -4478,7 +4478,7 @@ DYNAMIC_API PEP_STATUS get_crashdump_log(
int result;
do {
result = sqlite3_step(session->crashdump);
result = Sqlite3_step(session->crashdump);
switch (result) {
case SQLITE_ROW:
timestamp = (const char *) sqlite3_column_text(session->crashdump,
@ -4570,7 +4570,7 @@ DYNAMIC_API PEP_STATUS get_languagelist(
int result;
do {
result = sqlite3_step(session->languagelist);
result = Sqlite3_step(session->languagelist);
switch (result) {
case SQLITE_ROW:
lang = (const char *) sqlite3_column_text(session->languagelist,
@ -4638,7 +4638,7 @@ DYNAMIC_API PEP_STATUS get_phrase(
const char *_phrase = NULL;
int result;
result = sqlite3_step(session->i18n_token);
result = Sqlite3_step(session->i18n_token);
switch (result) {
case SQLITE_ROW:
_phrase = (const char *) sqlite3_column_text(session->i18n_token, 0);
@ -4680,7 +4680,7 @@ static PEP_STATUS _get_sequence_value(PEP_SESSION session, const char *name,
sqlite3_reset(session->sequence_value2);
sqlite3_bind_text(session->sequence_value2, 1, name, -1,
SQLITE_STATIC);
int result = sqlite3_step(session->sequence_value2);
int result = Sqlite3_step(session->sequence_value2);
switch (result) {
case SQLITE_ROW: {
int32_t _value = (int32_t)
@ -4708,7 +4708,7 @@ static PEP_STATUS _increment_sequence_value(PEP_SESSION session,
sqlite3_reset(session->sequence_value1);
sqlite3_bind_text(session->sequence_value1, 1, name, -1, SQLITE_STATIC);
int result = sqlite3_step(session->sequence_value1);
int result = Sqlite3_step(session->sequence_value1);
assert(result == SQLITE_DONE);
sqlite3_reset(session->sequence_value1);
if (result == SQLITE_DONE)
@ -4769,7 +4769,7 @@ PEP_STATUS is_own_key(PEP_SESSION session, const char* fpr, bool* own_key) {
sqlite3_bind_text(session->own_key_is_listed, 1, fpr, -1,
SQLITE_STATIC);
int result = sqlite3_step(session->own_key_is_listed);
int result = Sqlite3_step(session->own_key_is_listed);
switch (result) {
case SQLITE_ROW: {
*own_key = (sqlite3_column_int(session->own_key_is_listed, 0) != 0);
@ -4813,7 +4813,7 @@ DYNAMIC_API PEP_STATUS set_revoked(
int result;
result = sqlite3_step(session->set_revoked);
result = Sqlite3_step(session->set_revoked);
switch (result) {
case SQLITE_DONE:
status = PEP_STATUS_OK;
@ -4855,7 +4855,7 @@ DYNAMIC_API PEP_STATUS get_revoked(
int result;
result = sqlite3_step(session->get_revoked);
result = Sqlite3_step(session->get_revoked);
switch (result) {
case SQLITE_ROW: {
*revoked_fpr = strdup((const char *)
@ -4899,7 +4899,7 @@ DYNAMIC_API PEP_STATUS get_replacement_fpr(
int result;
result = sqlite3_step(session->get_replacement_fpr);
result = Sqlite3_step(session->get_replacement_fpr);
switch (result) {
case SQLITE_ROW: {
*revoked_fpr = strdup((const char *)
@ -4938,7 +4938,7 @@ PEP_STATUS get_last_contacted(
sqlite3_reset(session->get_last_contacted);
int result;
while ((result = sqlite3_step(session->get_last_contacted)) == SQLITE_ROW) {
while ((result = Sqlite3_step(session->get_last_contacted)) == SQLITE_ROW) {
pEp_identity *ident = new_identity(
(const char *) sqlite3_column_text(session->get_last_contacted, 1),
NULL,


+ 12
- 0
src/pEp_internal.h View File

@ -475,3 +475,15 @@ static inline void _init_globals() {
_pEp_rand_max_bits = (int) ceil(log2((double) RAND_MAX));
_pEp_log2_36 = log2(36);
}
// spinlock implementation
static inline int Sqlite3_step(sqlite3_stmt* stmt)
{
int rc;
do {
rc = sqlite3_step(stmt);
} while (rc == SQLITE_BUSY || rc == SQLITE_LOCKED);
return rc;
}

+ 6
- 6
src/pgp_sequoia.c View File

@ -446,7 +446,7 @@ static PEP_STATUS key_load(PEP_SESSION session, sqlite3_stmt *stmt,
pgp_tpk_t *tpkp, int *secretp)
{
PEP_STATUS status = PEP_STATUS_OK;
int sqlite_result = sqlite3_step(stmt);
int sqlite_result = Sqlite3_step(stmt);
switch (sqlite_result) {
case SQLITE_ROW:
if (tpkp) {
@ -692,7 +692,7 @@ static PEP_STATUS tpk_save(PEP_SESSION session, pgp_tpk_t tpk,
char *name = NULL;
sqlite3_stmt *stmt = session->sq_sql.begin_transaction;
int sqlite_result = sqlite3_step(stmt);
int sqlite_result = Sqlite3_step(stmt);
sqlite3_reset(stmt);
if (sqlite_result != SQLITE_DONE)
ERROR_OUT(NULL, PEP_UNKNOWN_ERROR,
@ -738,7 +738,7 @@ static PEP_STATUS tpk_save(PEP_SESSION session, pgp_tpk_t tpk,
sqlite3_bind_int(stmt, 2, is_tsk);
sqlite3_bind_blob(stmt, 3, tsk_buffer, tsk_buffer_len, SQLITE_STATIC);
sqlite_result = sqlite3_step(stmt);
sqlite_result = Sqlite3_step(stmt);
sqlite3_reset(stmt);
if (sqlite_result != SQLITE_DONE)
ERROR_OUT(NULL, PEP_UNKNOWN_ERROR,
@ -756,7 +756,7 @@ static PEP_STATUS tpk_save(PEP_SESSION session, pgp_tpk_t tpk,
sqlite3_bind_text(stmt, 1, keyid_hex, -1, SQLITE_STATIC);
sqlite3_bind_text(stmt, 2, fpr, -1, SQLITE_STATIC);
sqlite_result = sqlite3_step(stmt);
sqlite_result = Sqlite3_step(stmt);
sqlite3_reset(stmt);
free(keyid_hex);
pgp_keyid_free(keyid);
@ -846,7 +846,7 @@ static PEP_STATUS tpk_save(PEP_SESSION session, pgp_tpk_t tpk,
sqlite3_bind_text(stmt, 1, email, -1, SQLITE_STATIC);
sqlite3_bind_text(stmt, 2, fpr, -1, SQLITE_STATIC);
sqlite_result = sqlite3_step(stmt);
sqlite_result = Sqlite3_step(stmt);
sqlite3_reset(stmt);
if (sqlite_result != SQLITE_DONE) {
@ -880,7 +880,7 @@ static PEP_STATUS tpk_save(PEP_SESSION session, pgp_tpk_t tpk,
stmt = status == PEP_STATUS_OK
? session->sq_sql.commit_transaction
: session->sq_sql.rollback_transaction;
int sqlite_result = sqlite3_step(stmt);
int sqlite_result = Sqlite3_step(stmt);
sqlite3_reset(stmt);
if (sqlite_result != SQLITE_DONE)
ERROR_OUT(NULL, PEP_UNKNOWN_ERROR,


+ 1
- 1
sync/sql_func.yml2 View File

@ -31,7 +31,7 @@ function "exec_sql_int" {
call "init_sql" with "sql", "$sql";
||
int _result = 0;
int_result = sqlite3_step(_sql);
int_result = Sqlite3_step(_sql);
assert(int_result == SQLITE_ROW);
if (int_result == SQLITE_ROW)
_result = sqlite3_column_int(_sql, 0);


Loading…
Cancel
Save