sync : make sure that group wins election on both sides when a new device enters a group
authorEdouard Tisserant <edouard@pep-project.org>
Thu, 27 Oct 2016 17:01:20 +0200
changeset 1340276625d4f083
parent 1339 a8b118fae4ae
child 1344 bdde3e670d9d
child 1345 3c27d945fe92
sync : make sure that group wins election on both sides when a new device enters a group
src/sync_impl.c
     1.1 --- a/src/sync_impl.c	Thu Oct 27 10:15:31 2016 +0200
     1.2 +++ b/src/sync_impl.c	Thu Oct 27 17:01:20 2016 +0200
     1.3 @@ -42,6 +42,7 @@
     1.4      if (!(session && sync_msg))
     1.5          return PEP_ILLEGAL_VALUE;
     1.6  
     1.7 +    bool msgIsFromGroup = false;
     1.8      if(sync_msg->is_a_message){
     1.9          DeviceGroup_Protocol_t *msg = sync_msg->u.message;
    1.10          assert(msg && msg->payload.present != DeviceGroup_Protocol__payload_PR_NOTHING);
    1.11 @@ -50,6 +51,8 @@
    1.12              goto error;
    1.13          }
    1.14  
    1.15 +        msgIsFromGroup = msg->header.devicegroup;
    1.16 +
    1.17          switch (msg->payload.present) {
    1.18              case DeviceGroup_Protocol__payload_PR_beacon:
    1.19                  event = Beacon;
    1.20 @@ -164,6 +167,9 @@
    1.21  
    1.22              // finaly add partner to DB
    1.23              status = set_identity(session, tmpident);
    1.24 +            assert(status == PEP_STATUS_OK);
    1.25 +            if(status == PEP_STATUS_OK && msgIsFromGroup)
    1.26 +                status = set_identity_flags(session, tmpident, PEP_idf_devicegroup);
    1.27              free_identity(tmpident);
    1.28              assert(status == PEP_STATUS_OK);
    1.29              if (status != PEP_STATUS_OK) {