sync_driver now is responsible to duplicate partner identity, and transmit ownership to each state invoked. fsm_DeviceState_inject doesn't take ownership anymore keysync
authorEdouard Tisserant <edouard@pep-project.org>
Sun, 11 Sep 2016 22:40:59 +0200
branchkeysync
changeset 11577d383681ef2f
parent 1156 23006f389f2f
child 1158 91f23957e964
sync_driver now is responsible to duplicate partner identity, and transmit ownership to each state invoked. fsm_DeviceState_inject doesn't take ownership anymore
src/sync_impl.c
sync/gen_statemachine.ysl2
     1.1 --- a/src/sync_impl.c	Sun Sep 11 22:32:22 2016 +0200
     1.2 +++ b/src/sync_impl.c	Sun Sep 11 22:40:59 2016 +0200
     1.3 @@ -55,7 +55,11 @@
     1.4              return PEP_SYNC_ILLEGAL_MESSAGE;
     1.5      }
     1.6  
     1.7 -    return fsm_DeviceState_inject(session, event, partner, extra);
     1.8 +    PEP_STATUS result = fsm_DeviceState_inject(session, event, partner, extra);
     1.9 +
    1.10 +    free_identity(partner);
    1.11 +
    1.12 +    return result;
    1.13  }
    1.14  
    1.15  PEP_STATUS receive_DeviceState_msg(PEP_SESSION session, message *src, PEP_rating rating)
     2.1 --- a/sync/gen_statemachine.ysl2	Sun Sep 11 22:32:22 2016 +0200
     2.2 +++ b/sync/gen_statemachine.ysl2	Sun Sep 11 22:40:59 2016 +0200
     2.3 @@ -141,18 +141,22 @@
     2.4  
     2.5              while(true)
     2.6              {
     2.7 +                Identity _partner = partner ? identity_dup(partner) : NULL;
     2.8 +
     2.9                  «@name»_state new_state = fsm_«@name»(session,
    2.10 -                    session->«@filename»_state, event, partner, extra);
    2.11 +                    session->«@filename»_state, event, _partner, extra);
    2.12 +
    2.13                  if (new_state == «@name»_state_invalid_out_of_memory)
    2.14                      return PEP_OUT_OF_MEMORY;
    2.15 +
    2.16                  if (new_state < 0)
    2.17                      return PEP_SYNC_STATEMACHINE_ERROR - new_state;
    2.18                  
    2.19 -                if (new_state == session->sync_state)
    2.20 +                if (new_state == session->«@filename»_state)
    2.21                      break;
    2.22 -                else
    2.23 -                    event = Init;
    2.24  
    2.25 +                event = Init;
    2.26 +                extra = NULL;
    2.27                  session->«@filename»_state = new_state;
    2.28              } 
    2.29  
    2.30 @@ -193,7 +197,7 @@
    2.31      ||
    2.32      case «@name»:
    2.33          switch (event) {
    2.34 -        ``if "not(event[@name='Init'])" |>> case Init: break;
    2.35 +        `` if "not(event[@name='Init'])" |>> case Init: break;
    2.36          `` apply "event", 2
    2.37              default:
    2.38                  return («../@name»_state) invalid_event;