ENGINE-398: obvious SQL runtime errors fixed, but we need to set up an external sync dummy, and there is now a weird problem with key_reset_trust; will have to check the test case. ENGINE-398
authorKrista Bennett <krista@pep-project.org>
Tue, 21 Aug 2018 16:21:23 +0200
branchENGINE-398
changeset 2862fd6fb5f6d437
parent 2861 43a404e78276
child 2863 f801618a045c
ENGINE-398: obvious SQL runtime errors fixed, but we need to set up an external sync dummy, and there is now a weird problem with key_reset_trust; will have to check the test case.
src/message_api.c
src/pEpEngine.c
src/pEpEngine.h
     1.1 --- a/src/message_api.c	Tue Aug 21 12:27:32 2018 +0200
     1.2 +++ b/src/message_api.c	Tue Aug 21 16:21:23 2018 +0200
     1.3 @@ -3777,6 +3777,8 @@
     1.4      assert(status != PEP_STATUS_OK); // FIXME: FOR DEBUGGING ONLY DO NOT LEAVE IN    
     1.5      if (status != PEP_STATUS_OK) {
     1.6          // This should really never choke unless the DB is broken.
     1.7 +        status = PEP_UNKNOWN_DB_ERROR;
     1.8 +        goto pep_error;
     1.9      }
    1.10      
    1.11      stringpair_list_t* curr_pair_node;
    1.12 @@ -3803,10 +3805,18 @@
    1.13                  goto pep_error;
    1.14              }
    1.15              // insert into queue
    1.16 -            int result = session->sync_session->inject_sync_msg(reset_msg, 
    1.17 -                                                                session->sync_session->sync_management);
    1.18 -
    1.19 -            if (result == 0) {    
    1.20 +            if (session->messageToSend) {
    1.21 +                status = session->messageToSend(session->sync_obj, reset_msg);
    1.22 +            } 
    1.23 +            else if (session->sync_session->messageToSend) {
    1.24 +                status = session->sync_session->messageToSend(session->sync_session->sync_obj, 
    1.25 +                                                              reset_msg); 
    1.26 +            }
    1.27 +            else {
    1.28 +                status = PEP_SYNC_NO_MESSAGE_SEND_CALLBACK;
    1.29 +            }
    1.30 +
    1.31 +            if (status == PEP_STATUS_OK) {    
    1.32                  // Put into notified DB
    1.33                  status = set_reset_contact_notified(session, curr_pair->key, msg->from->user_id);
    1.34                  if (status != PEP_STATUS_OK) // It's ok to barf because it's a DB problem??
    1.35 @@ -3814,12 +3824,10 @@
    1.36              }
    1.37              else {
    1.38                  // According to Volker, this would only be a fatal error, so...
    1.39 -                status = PEP_SYNC_INJECT_FAILED; // FIXME: see what can happen here
    1.40 +                free_message(reset_msg); // ??
    1.41 +                reset_msg = NULL; // ??
    1.42                  goto pep_error;
    1.43              }
    1.44 -        
    1.45 -            free_message(reset_msg);
    1.46 -            reset_msg = NULL;
    1.47          }
    1.48      }
    1.49      
     2.1 --- a/src/pEpEngine.c	Tue Aug 21 12:27:32 2018 +0200
     2.2 +++ b/src/pEpEngine.c	Tue Aug 21 16:21:23 2018 +0200
     2.3 @@ -450,7 +450,7 @@
     2.4  // We only need user_id and address, since in the main usage, we'll call update_identity
     2.5  // on this anyway when sending out messages.
     2.6  static const char *sql_get_last_contacted =
     2.7 -    "select userid, address from identity where datetime('now') < datetime(timestamp, '+14 days') ; ";
     2.8 +    "select user_id, address from identity where datetime('now') < datetime(timestamp, '+14 days') ; ";
     2.9      
    2.10  static int user_version(void *_version, int count, char **text, char **name)
    2.11  {
    2.12 @@ -751,7 +751,7 @@
    2.13                  "    CONSTRAINT fk_own_identity\n"
    2.14                  "       FOREIGN KEY(own_address, own_userid)\n" 
    2.15                  "       REFERENCES identity(address, user_id)\n"
    2.16 -                "       ON DELETE CASCADE ON UPDATE CASCADE,\n"
    2.17 +                "       ON DELETE CASCADE ON UPDATE CASCADE\n"
    2.18                  ");\n"
    2.19                  // list of user_ids sent revocation
    2.20                  "create table if not exists revocation_contact_list (\n"
     3.1 --- a/src/pEpEngine.h	Tue Aug 21 12:27:32 2018 +0200
     3.2 +++ b/src/pEpEngine.h	Tue Aug 21 16:21:23 2018 +0200
     3.3 @@ -96,6 +96,7 @@
     3.4      PEP_SYNC_ILLEGAL_MESSAGE                        = 0x0902,
     3.5      PEP_SYNC_NO_INJECT_CALLBACK                     = 0x0903,
     3.6      PEP_SYNC_INJECT_FAILED                          = 0x0904,
     3.7 +    PEP_SYNC_NO_MESSAGE_SEND_CALLBACK               = 0x0905,
     3.8  
     3.9      PEP_SEQUENCE_VIOLATED                           = 0x0970,
    3.10      PEP_CANNOT_INCREASE_SEQUENCE                    = 0x0971,