KeySync: added persistance of 'own' flags to sequence value table so that UUID keeps marked as own, even after UUID change, otherwise leading to recapture of own messages
authorEdouard Tisserant <edouard@pep-project.org>
Wed, 22 Feb 2017 19:26:45 +0100
changeset 1602904da6719597
parent 1601 10e4e77e2278
child 1603 f954f77387f1
KeySync: added persistance of 'own' flags to sequence value table so that UUID keeps marked as own, even after UUID change, otherwise leading to recapture of own messages
src/pEpEngine.c
test/sequence_test.cc
     1.1 --- a/src/pEpEngine.c	Tue Feb 21 23:08:01 2017 +0100
     1.2 +++ b/src/pEpEngine.c	Wed Feb 22 19:26:45 2017 +0100
     1.3 @@ -160,14 +160,16 @@
     1.4  static const char *sql_sequence_value1 = 
     1.5      "insert or replace into sequences (name, value, own) "
     1.6      "values (?1, "
     1.7 -    "(select coalesce((select value + 1 from sequences "
     1.8 -    "where name = ?1), 1 )), ?2) ; ";
     1.9 +    "       (select coalesce((select value + 1 from sequences "
    1.10 +    "           where name = ?1), 1 )), "
    1.11 +    "       (select coalesce((select own or ?2 from sequences "
    1.12 +    "           where name = ?1), ?2))) ; ";
    1.13  
    1.14  static const char *sql_sequence_value2 = 
    1.15      "select value, own from sequences where name = ?1 ;";
    1.16  
    1.17  static const char *sql_sequence_value3 = 
    1.18 -    "update sequences set value = ?2, own = ?3 where name = ?1 ;";
    1.19 +    "update sequences set value = ?2, own = (select own or ?3 from sequences where name = ?1) where name = ?1 ;";
    1.20          
    1.21  // Revocation tracking
    1.22  static const char *sql_set_revoked =
     2.1 --- a/test/sequence_test.cc	Tue Feb 21 23:08:01 2017 +0100
     2.2 +++ b/test/sequence_test.cc	Wed Feb 22 19:26:45 2017 +0100
     2.3 @@ -39,7 +39,7 @@
     2.4  //    free(name1);
     2.5  
     2.6      cout << "testing sequence violation\n";
     2.7 -    int32_t value3 = value2 - 1;
     2.8 +    int32_t value3 = value2;
     2.9      PEP_STATUS status4 = sequence_value(session, name1, &value3);
    2.10      assert(status4 == PEP_SEQUENCE_VIOLATED);
    2.11