better this way sync
authorVolker Birk <vb@pep.foundation>
Thu, 30 Aug 2018 08:17:34 +0200
branchsync
changeset 2914f14346676e85
parent 2913 b2c2eed5be7a
child 2915 f53f154a4fc2
better this way
sync/cond_act_sync.yml2
sync/gen_actions.ysl2
sync/gen_statemachine.ysl2
sync/sync.fsm
     1.1 --- a/sync/cond_act_sync.yml2	Thu Aug 30 04:33:59 2018 +0200
     1.2 +++ b/sync/cond_act_sync.yml2	Thu Aug 30 08:17:34 2018 +0200
     1.3 @@ -152,7 +152,7 @@
     1.4  action showGroupedHandshake
     1.5      call "show_handshake" with "type" > SYNC_NOTIFY_INIT_ADD_OTHER_DEVICE
     1.6  
     1.7 -action KeySyncTimeoutHandler
     1.8 +timeout KeySync
     1.9      call "show_handshake" with "type" > SYNC_NOTIFY_TIMEOUT
    1.10  
    1.11  action saveGroupKeys
     2.1 --- a/sync/gen_actions.ysl2	Thu Aug 30 04:33:59 2018 +0200
     2.2 +++ b/sync/gen_actions.ysl2	Thu Aug 30 08:17:34 2018 +0200
     2.3 @@ -17,6 +17,11 @@
     2.4  decl condition is _func (*type="condition");
     2.5  decl action is _func (*type="action");
     2.6  
     2.7 +decl timeout *name alias - {
     2.8 +    template %name=*name, "fsm[@name='%name']", mode=handler
     2.9 +        call "fsm" with "content" content;
    2.10 +};
    2.11 +
    2.12  tstylesheet {
    2.13      include standardlib.ysl2
    2.14      include ./functions.ysl2
    2.15 @@ -61,7 +66,7 @@
    2.16              ||
    2.17              apply "func:distinctName(//condition)", 0;
    2.18              apply "func:distinctName(//action)", 0;
    2.19 -            callTimeoutHandler KeySync;
    2.20 +            apply "/protocol/fsm", 0, mode=handler;
    2.21          }
    2.22      }
    2.23  
    2.24 @@ -105,5 +110,24 @@
    2.25  
    2.26          ||
    2.27      }
    2.28 +
    2.29 +    function "fsm" {
    2.30 +        param "content";
    2.31 +        ||
    2.32 +        PEP_STATUS «@name»TimeoutHandler(PEP_SESSION session)
    2.33 +        {
    2.34 +            assert(session);
    2.35 +            if (!session)
    2.36 +                return PEP_ILLEGAL_VALUE;
    2.37 +
    2.38 +        ||
    2.39 +        copy "$content";
    2.40 +        ||
    2.41 +
    2.42 +            return PEP_STATUS_OK;
    2.43 +        }
    2.44 +
    2.45 +        ||
    2.46 +    }
    2.47  }
    2.48  
     3.1 --- a/sync/gen_statemachine.ysl2	Thu Aug 30 04:33:59 2018 +0200
     3.2 +++ b/sync/gen_statemachine.ysl2	Thu Aug 30 08:17:34 2018 +0200
     3.3 @@ -146,6 +146,13 @@
     3.4                  | PEP_STATUS «@name»(PEP_SESSION session);
     3.5              ||
     3.6  
     3.7 +            // timeout handler
     3.8 +            
     3.9 +            ||
    3.10 +            for "fsm[@threshold > 0]"
    3.11 +                | PEP_STATUS «@name»TimeoutHandler(PEP_SESSION session);
    3.12 +            ||
    3.13 +
    3.14              // send message about an event to communication partners using state
    3.15  
    3.16              PEP_STATUS send_«@name»_message(
    3.17 @@ -553,7 +560,7 @@
    3.18                      if (_«@name»_timeout(state)) {
    3.19                          session->«yml:lcase(../@name)»_state.«yml:lcase(@name)».state = Init;
    3.20                          event = Init;
    3.21 -                        `` if "action" |>>>>> «action/@name»(session);
    3.22 +                        `` if "@threshold > 0" |>>>>> «@name»TimeoutHandler(session);
    3.23                      }
    3.24                      break;
    3.25                  
     4.1 --- a/sync/sync.fsm	Thu Aug 30 04:33:59 2018 +0200
     4.2 +++ b/sync/sync.fsm	Thu Aug 30 08:17:34 2018 +0200
     4.3 @@ -12,7 +12,6 @@
     4.4  
     4.5      fsm KeySync 1 {
     4.6          version 1, 2;
     4.7 -        action KeySyncTimeoutHandler;
     4.8  
     4.9          state InitState {
    4.10              on Init {