From efd84940d863eb0f02361cdad38eec4956650ae8 Mon Sep 17 00:00:00 2001 From: Yasuyuki Tanaka Date: Wed, 12 Jul 2017 11:07:41 +0900 Subject: [PATCH] sixtop: start transaction timer in its allocation process While the timer is designed to get started on state transition from SIXP_TRANS_STATE_INIT, the state transition may not happen in some erroneous situation. This change makes sure that the timer is started once it's allocated. --- os/net/mac/tsch/sixtop/sixp-trans.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/os/net/mac/tsch/sixtop/sixp-trans.c b/os/net/mac/tsch/sixtop/sixp-trans.c index 85d053047..feb2c0631 100644 --- a/os/net/mac/tsch/sixtop/sixp-trans.c +++ b/os/net/mac/tsch/sixtop/sixp-trans.c @@ -98,6 +98,13 @@ handle_trans_timeout(void *ptr) } /*---------------------------------------------------------------------------*/ static void +start_trans_timer(sixp_trans_t *trans) +{ + ctimer_set(&trans->timer, trans->sf->timeout_interval, + handle_trans_timeout, trans); +} +/*---------------------------------------------------------------------------*/ +static void process_trans(void *ptr) { sixp_trans_t *trans = (sixp_trans_t *)ptr; @@ -139,8 +146,7 @@ process_trans(void *ptr) if(trans->state != SIXP_TRANS_STATE_TERMINATING) { /* set the timer with a timeout values defined by the SF */ - ctimer_set(&trans->timer, trans->sf->timeout_interval, - handle_trans_timeout, trans); + start_trans_timer(trans); } } /*---------------------------------------------------------------------------*/ @@ -338,6 +344,7 @@ sixp_trans_alloc(const sixp_pkt_t *pkt, const linkaddr_t *peer_addr) trans->state = SIXP_TRANS_STATE_INIT; trans->mode = determine_trans_mode(pkt); list_add(trans_list, trans); + start_trans_timer(trans); return trans; }