sync/gen_statemachine.ysl2
branchkeysync
changeset 1152 fde1a69448d2
parent 1099 113463c3e85a
child 1157 7d383681ef2f
     1.1 --- a/sync/gen_statemachine.ysl2	Thu Sep 08 12:57:58 2016 +0200
     1.2 +++ b/sync/gen_statemachine.ysl2	Thu Sep 08 16:40:20 2016 +0200
     1.3 @@ -139,14 +139,23 @@
     1.4              if (!session)
     1.5                  return PEP_ILLEGAL_VALUE;
     1.6  
     1.7 -            «@name»_state state = fsm_«@name»(session,
     1.8 +            while(true)
     1.9 +            {
    1.10 +                «@name»_state new_state = fsm_«@name»(session,
    1.11                      session->«@filename»_state, event, partner, extra);
    1.12 -            if (state == «@name»_state_invalid_out_of_memory)
    1.13 -                return PEP_OUT_OF_MEMORY;
    1.14 -            if (state < 0)
    1.15 -                return PEP_SYNC_STATEMACHINE_ERROR - state;
    1.16 +                if (new_state == «@name»_state_invalid_out_of_memory)
    1.17 +                    return PEP_OUT_OF_MEMORY;
    1.18 +                if (new_state < 0)
    1.19 +                    return PEP_SYNC_STATEMACHINE_ERROR - new_state;
    1.20 +                
    1.21 +                if (new_state == session->sync_state)
    1.22 +                    break;
    1.23 +                else
    1.24 +                    event = Init;
    1.25  
    1.26 -            session->«@filename»_state = state;
    1.27 +                session->«@filename»_state = new_state;
    1.28 +            } 
    1.29 +
    1.30              return PEP_STATUS_OK;
    1.31          }
    1.32  
    1.33 @@ -184,6 +193,7 @@
    1.34      ||
    1.35      case «@name»:
    1.36          switch (event) {
    1.37 +        ``if "not(event[@name='Init'])" |>> case Init: break;
    1.38          `` apply "event", 2
    1.39              default:
    1.40                  return («../@name»_state) invalid_event;